/** * 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; }
/** * @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()); }
/** * @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); }