Skip to content

Allow span 'kind' to be set (e.g. CLIENT|SERVER|CONSUMER|PRODUCER) #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Contracts/Tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ interface Tracer
* @param string $name
* @param SpanContext|null $spanContext
* @param int|null $timestamp intval(microtime(true) * 1000000)
* @param string|null $kind
* @return Span
*/
public function startSpan(string $name, SpanContext $spanContext = null, ?int $timestamp = null): Span;
public function startSpan(string $name, SpanContext $spanContext = null, ?int $timestamp = null, ?string $kind = null): Span;

/**
* Retrieve the root span of the service
Expand Down
6 changes: 5 additions & 1 deletion src/Drivers/Zipkin/ZipkinTracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,15 @@ public function init(): Tracer
* @param string $name
* @param SpanContext|null $spanContext
* @param int|null $timestamp intval(microtime(true) * 1000000)
* @param string|null $kind
* @return Span
*/
public function startSpan(string $name, ?SpanContext $spanContext = null, ?int $timestamp = null): Span
public function startSpan(string $name, ?SpanContext $spanContext = null, ?int $timestamp = null, ?string $kind = null): Span
{
$rawSpan = $this->tracing->getTracer()->nextSpan($spanContext ? $spanContext->getRawContext() : null);
if ($kind) {
$rawSpan->setKind($kind);
}

if ($this->rootSpan) {
$span = new ZipkinSpan($rawSpan, false);
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/Trace.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* @see \Vinelab\Tracing\Contracts\Tracer
*
* @method static Span startSpan(string $name, SpanContext $spanContext = null, ?int $timestamp = null)
* @method static Span startSpan(string $name, SpanContext $spanContext = null, ?int $timestamp = null, $kind = null)
* @method static Span getRootSpan()
* @method static Span getCurrentSpan()
* @method static string|null getUUID()
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/TraceRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function handle(Request $request, Closure $next)
if (!$this->shouldBeExcluded($request->path())) {
$spanContext = $this->tracer->extract($request, Formats::ILLUMINATE_HTTP);

$span = $this->tracer->startSpan('Http Request', $spanContext);
$span = $this->tracer->startSpan('Http Request', $spanContext, null, \Zipkin\Kind\SERVER);

$this->tagRequestData($span, $request);
}
Expand Down