current() public method

Get the current span in the stack.
public current ( ) : Span | null
return Tolerance\Tracer\Span\Span | null
Esempio n. 1
0
 /**
  * Updates the record with the span identifiers.
  *
  * @param array $record
  *
  * @return array
  */
 public function __invoke(array $record)
 {
     if (null === ($span = $this->spanStack->current())) {
         return $record;
     }
     $record['context']['tags'] = ['span_id' => (string) $span->getIdentifier(), 'trace_id' => (string) $span->getTraceIdentifier()];
     return $record;
 }
Esempio n. 2
0
 /**
  * @param AMQPMessage $message
  *
  * @return Span
  */
 public function fromProducedMessage(AMQPMessage $message)
 {
     $currentSpan = $this->spanStack->current();
     return new Span($this->identifierGenerator->generate(), $this->getMessageName($message), null !== $currentSpan ? $currentSpan->getTraceIdentifier() : $this->identifierGenerator->generate(), [new Annotation(Annotation::CLIENT_SEND, $this->clock->microseconds(), $this->endpointResolver->resolve())], [], $currentSpan !== null ? $currentSpan->getIdentifier() : null, $currentSpan !== null ? $currentSpan->getDebug() : null, $this->clock->microseconds());
 }
Esempio n. 3
0
 /**
  * @param RequestInterface $request
  *
  * @return 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->getUri()->getHost(), BinaryAnnotation::TYPE_STRING), new BinaryAnnotation('http.path', $request->getUri()->getPath(), BinaryAnnotation::TYPE_STRING), new BinaryAnnotation('http.method', $request->getMethod(), BinaryAnnotation::TYPE_STRING)], $currentSpan !== null ? $currentSpan->getIdentifier() : null, $currentSpan !== null ? $currentSpan->getDebug() : null);
 }