I'm implementing the APM instrumentation for the ASP.NET CORE application. The application sends and receives messages to/from Service Bus. I found in the documentation (Supported technologies | APM .NET Agent Reference [1.11] | Elastic) that the Azure Service Bus is supported technology by Elastic APM for 3.0.0+ Microsoft.Azure.ServiceBus library. I pulled the Elastic.Apm.Azure.ServiceBus NuGet into the project, and added MicrosoftAzureServiceBusDiagnosticsSubscriber to the Startup.cs configuration like shown below:
app.UseElasticApm( _configuration, new AspNetCoreDiagnosticSubscriber(), new HttpDiagnosticsSubscriber(), new MicrosoftAzureServiceBusDiagnosticsSubscriber(), new AzureCosmosDbDiagnosticsSubscriber());
The documentation says that A new transaction is created for received and receive deferred messages. Indeed, the transaction is created, but there are no child spans e.g. for HTTP or Database calls, that are performed while handling messages received from Service Bus. I've decided to remove MicrosoftAzureServiceBusDiagnosticsSubscriber and check whether it works when I'll create the transaction explicitly in the code, and it looks like everything is reported correctly then. You can see the timeline of those two approaches in the images below.
Transaction created automatically by MicrosoftAzureServiceBusDiagnosticsSubscriber
Transaction created explicitly in the code that handles Service Bus message Agent.Tracer.CaptureTransaction(...)
- Elastic.Apm.Azure.ServiceBus 1.11.1
- Microsoft.Azure.ServiceBus 5.1.3
- Elastic stack 7.14.1
Can someone take a look on that and answer why the child spans are not tracked while using nuget instrumentation? Is there something wrong with the configuration?