Skip to content

Commit

Permalink
Merge pull request #2 from Vinelab/graceful_inject
Browse files Browse the repository at this point in the history
Define errors out of existence
  • Loading branch information
adiachenko authored Aug 27, 2019
2 parents 9374389 + 8d0a221 commit b50987e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
7 changes: 0 additions & 7 deletions src/Drivers/Null/NullTracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Vinelab\Tracing\Contracts\Span;
use Vinelab\Tracing\Contracts\SpanContext;
use Vinelab\Tracing\Contracts\Tracer;
use Vinelab\Tracing\Exceptions\MissingTraceContextException;

class NullTracer implements Tracer
{
Expand Down Expand Up @@ -97,12 +96,6 @@ public function extract($carrier, string $format): ?SpanContext
*/
public function inject($carrier, string $format)
{
$span = $this->getCurrentSpan();

if (!$span) {
throw new MissingTraceContextException('Cannot obtain context because there is no active span');
}

return $carrier;
}

Expand Down
11 changes: 4 additions & 7 deletions src/Drivers/Zipkin/ZipkinTracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Vinelab\Tracing\Drivers\Zipkin\Injectors\TextMapInjector;
use Vinelab\Tracing\Drivers\Zipkin\Injectors\VinelabHttpInjector;
use Vinelab\Tracing\Drivers\Zipkin\Injectors\ZipkinInjector;
use Vinelab\Tracing\Exceptions\MissingTraceContextException;
use Vinelab\Tracing\Exceptions\UnregisteredFormatException;
use Vinelab\Tracing\Exceptions\UnresolvedCollectorIpException;
use Vinelab\Tracing\Propagation\Formats;
Expand Down Expand Up @@ -241,14 +240,12 @@ public function inject($carrier, string $format)
{
$span = $this->getCurrentSpan();

if (!$span) {
throw new MissingTraceContextException('Cannot obtain context because there is no active span');
if ($span) {
$this->resolveInjector($format)
->setPropagation($this->tracing->getPropagation())
->inject($span->getContext(), $carrier);
}

$this->resolveInjector($format)
->setPropagation($this->tracing->getPropagation())
->inject($span->getContext(), $carrier);

return $carrier;
}

Expand Down
10 changes: 0 additions & 10 deletions src/Exceptions/MissingTraceContextException.php

This file was deleted.

0 comments on commit b50987e

Please sign in to comment.