Tolerance\Tracer\SpanFactory\Amqp\AmqpSpanFactory::fromProducedMessage PHP Method

fromProducedMessage() public method

public fromProducedMessage ( PhpAmqpLib\Message\AMQPMessage $message ) : Span
$message PhpAmqpLib\Message\AMQPMessage
return Tolerance\Tracer\Span\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());
    }

Usage Example

Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function publish($msgBody, $routingKey = '', $additionalProperties = array())
 {
     $message = new AMQPMessage((string) $msgBody, array_merge($additionalProperties, ['routing_key' => $routingKey]));
     $span = $this->amqpSpanFactory->fromProducedMessage($message);
     if (!array_key_exists('application_headers', $additionalProperties)) {
         $additionalProperties['application_headers'] = new AMQPTable();
     } elseif (!$additionalProperties['application_headers'] instanceof AMQPTable) {
         throw new \InvalidArgumentException('Your `application_headers` must be an `AMQPTable`');
     }
     $headers = $additionalProperties['application_headers'];
     $headers->set('X-B3-SpanId', (string) $span->getIdentifier());
     $headers->set('X-B3-TraceId', (string) $span->getTraceIdentifier());
     $headers->set('X-B3-ParentSpanId', (string) $span->getParentIdentifier());
     $headers->set('X-B3-Flags', $span->getDebug() ? '1' : '0');
     $result = $this->decoratedProducer->publish($msgBody, $routingKey, $additionalProperties);
     $this->tracer->trace([$span]);
     return $result;
 }
All Usage Examples Of Tolerance\Tracer\SpanFactory\Amqp\AmqpSpanFactory::fromProducedMessage