Add null check for envelope in consumer delegate
This commit is contained in:
parent
1671a4560b
commit
785860b6a7
|
|
@ -11,6 +11,7 @@ import datadog.trace.api.DDTags;
|
|||
import io.opentracing.Scope;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
import io.opentracing.Tracer;
|
||||
import io.opentracing.noop.NoopScopeManager;
|
||||
import io.opentracing.propagation.Format;
|
||||
import io.opentracing.tag.Tags;
|
||||
|
|
@ -80,7 +81,7 @@ public class TracedDelegatingConsumer implements Consumer {
|
|||
queueName = "<generated>";
|
||||
}
|
||||
|
||||
scope =
|
||||
final Tracer.SpanBuilder spanBuilder =
|
||||
GlobalTracer.get()
|
||||
.buildSpan("amqp.command")
|
||||
.asChildOf(parentContext)
|
||||
|
|
@ -90,11 +91,17 @@ public class TracedDelegatingConsumer implements Consumer {
|
|||
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CONSUMER)
|
||||
.withTag(Tags.COMPONENT.getKey(), "rabbitmq-amqp")
|
||||
.withTag("amqp.command", "basic.deliver")
|
||||
.withTag("amqp.exchange", envelope.getExchange())
|
||||
.withTag("amqp.routing_key", envelope.getRoutingKey())
|
||||
.withTag("message.size", body == null ? 0 : body.length)
|
||||
.withTag("span.origin.type", delegate.getClass().getName())
|
||||
.startActive(true);
|
||||
.withTag("span.origin.type", delegate.getClass().getName());
|
||||
|
||||
if (envelope != null) {
|
||||
spanBuilder
|
||||
.withTag("amqp.exchange", envelope.getExchange())
|
||||
.withTag("amqp.routing_key", envelope.getRoutingKey());
|
||||
}
|
||||
|
||||
scope = spanBuilder.startActive(true);
|
||||
|
||||
} finally {
|
||||
try {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue