Skip to content

Commit

Permalink
fix: Revert RabbitMQ HandleBasicDeliver instrumentation change from #…
Browse files Browse the repository at this point in the history
…1972. Resolves #2047 (#2118)
  • Loading branch information
tippmar-nr committed Dec 5, 2023
1 parent 6aae40d commit 0525182
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Expand Up @@ -30,7 +30,7 @@ SPDX-License-Identifier: Apache-2.0

<!-- Consume Push / Event / Subscribe -->
<tracerFactory name="HandleBasicDeliverWrapper">
<match assemblyName="RabbitMQ.Client" className="RabbitMQ.Client.Impl.ModelBase">
<match assemblyName="RabbitMQ.Client" className="RabbitMQ.Client.Events.EventingBasicConsumer">
<exactMethodMatcher methodName="HandleBasicDeliver" />
</match>
</tracerFactory>
Expand Down
@@ -1,4 +1,4 @@
// Copyright 2020 New Relic, Inc. All rights reserved.
// Copyright 2020 New Relic, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

// See this project's .csproj file for target framework => RabbitMQ.Client version mappings
Expand Down Expand Up @@ -227,11 +227,20 @@ void handler(object ch, BasicDeliverEventArgs basicDeliverEventArgs)
#endif
VerifyHeaders(basicDeliverEventArgs.BasicProperties.Headers);

InstrumentedChildMethod(); // to verify we're getting a child span

manualResetEvent.Set();
}
}
}

[Trace]
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
private void InstrumentedChildMethod()
{
Thread.Sleep(100);
}

private void VerifyHeaders(IDictionary<string, object> headers)
{
foreach (var userHeader in userHeaders)
Expand Down
Expand Up @@ -53,7 +53,9 @@ public void Test()
{
new Assertions.ExpectedMetric { metricName = "Supportability/DistributedTrace/CreatePayload/Success", callCount = 3 },
new Assertions.ExpectedMetric { metricName = "Supportability/TraceContext/Create/Success", callCount = 3 },
new Assertions.ExpectedMetric { metricName = "Supportability/TraceContext/Accept/Success", callCount = 2 }
new Assertions.ExpectedMetric { metricName = "Supportability/TraceContext/Accept/Success", callCount = 2 },
new Assertions.ExpectedMetric { metricName = "DotNet/MultiFunctionApplicationHelpers.NetStandardLibraries.RabbitMQ/InstrumentedChildMethod"} ,
new Assertions.ExpectedMetric { metricName = "DotNet/MultiFunctionApplicationHelpers.NetStandardLibraries.RabbitMQ/InstrumentedChildMethod", metricScope = "OtherTransaction/Message/RabbitMQ/Queue/Named/integrationTestQueue.*", IsRegexScope = true}
};

var metrics = _fixture.AgentLog.GetMetrics();
Expand Down

0 comments on commit 0525182

Please sign in to comment.