Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,24 @@ internal static CallTargetState OnMethodBegin<TTarget, TBasicProperties, TActivi
internal static CallTargetReturn<TReturn?> OnMethodEnd<TTarget, TReturn>(TTarget instance, TReturn returnValue, Exception? exception, in CallTargetState state)
{
var tracer = Tracer.Instance;
var activeSpan = tracer.ActiveScope?.Span;
if (activeSpan is not Span { Tags: RabbitMQTags tags } span
|| !RabbitMQIntegration.IsRabbitMqSpan(tracer, span, SpanKinds.Producer))

Span? span = null;
RabbitMQTags? tags = null;
var scope = tracer.ActiveScope as Scope;
while (scope is not null)
{
if (scope.Span is Span { Tags: RabbitMQTags candidateTags } candidateSpan
&& RabbitMQIntegration.IsRabbitMqSpan(tracer, candidateSpan, SpanKinds.Producer))
{
span = candidateSpan;
tags = candidateTags;
break;
}

scope = scope.Parent;
}

if (span is null || tags is null)
{
// We're not in a RabbitMQ span "produce", so bail out - either
// we didn't create an active scope for some reason (e.g integration disabled),
Expand Down
Loading