Tolerance\Bridge\Guzzle\Tracer\SpanFactory\GuzzleMessageSpanFactory::fromOutgoingRequest PHP Метод

fromOutgoingRequest() публичный Метод

public fromOutgoingRequest ( GuzzleHttp\Message\RequestInterface $request ) : Span
$request GuzzleHttp\Message\RequestInterface
Результат Tolerance\Tracer\Span\Span
    public function fromOutgoingRequest(RequestInterface $request)
    {
        $currentSpan = $this->spanStack->current();
        return new Span($this->identifierGenerator->generate(), $this->getName($request), null !== $currentSpan ? $currentSpan->getTraceIdentifier() : $this->identifierGenerator->generate(), [new Annotation(Annotation::CLIENT_SEND, $this->clock->microseconds(), $this->endpointResolver->resolve())], [new BinaryAnnotation('http.host', $request->getHost() ?: '', BinaryAnnotation::TYPE_STRING), new BinaryAnnotation('http.method', $request->getMethod() ?: '', BinaryAnnotation::TYPE_STRING), new BinaryAnnotation('http.path', $request->getPath() ?: '', BinaryAnnotation::TYPE_STRING)], $currentSpan !== null ? $currentSpan->getIdentifier() : null, $currentSpan !== null ? $currentSpan->getDebug() : null);
    }

Usage Example

Пример #1
0
 /**
  * @param BeforeEvent $event
  */
 public function onBefore(BeforeEvent $event)
 {
     $request = $event->getRequest();
     $span = $this->guzzleMessageSpanFactory->fromOutgoingRequest($request);
     $this->tracer->trace([$span]);
     $request->addHeaders(['X-B3-SpanId' => (string) $span->getIdentifier(), 'X-B3-TraceId' => (string) $span->getTraceIdentifier(), 'X-B3-ParentSpanId' => (string) $span->getParentIdentifier(), 'X-B3-Flags' => $span->getDebug() ? '1' : '0']);
 }