Scenario
I have an containerized, event-driven, microservices app in ASP .NET Core just migrated to .NET 5.
All projects are using Microsoft.ApplicationInsights 2.16.0, and I have checked that all telemetry is sent and Sampling does not affect the results (at least individually for each micro service).
All projects publish and subscribe events to RabbitMQ.
I have my own rabbitmq nuget package to ease the access to RabbitMQ (which has been working properly for more than a year). I added this code to send telemetry identificators when an event is published:
var operation = _telemetryClient.StartOperation<DependencyTelemetry>($"Publish {theEvent.EventName.Replace(".", "-")}");
operation.Telemetry.Type = "Azure Service Bus"; // Just because I like the icon shown in Azure.
operation.Telemetry.Data = JsonConvert.SerializeObject(theEvent);
_basicProperties.Headers["x-telemetry-operationid"] = operation.Telemetry.Context.Operation.Id;
_basicProperties.Headers["x-telemetry-parentOperationId"] = operation.Telemetry.Id;
_channelProvider
.GetChannel()
.BasicPublish(_configuration.Exchange, theEvent.EventName, _basicProperties, Encoding.UTF8.GetBytes(payload));
I used this code to track the dependency when an event is received:
var operation = _telemetryClient.StartOperation<RequestTelemetry>($"Received {eventName.Replace(".", "-")}");
operation.Telemetry.Context.Operation.Id = basicDeliverEventArgs.BasicProperties.Headers["x-telemetry-operationId"];
operation.Telemetry.Context.Operation.ParentId = basicDeliverEventArgs.BasicProperties.Headers["x-telemetry-operationId"];
// Handle the message...
_telemetryClient.StopOperation(operation);
When a micro service receives a POST request, it will trigger an event. Several other micro services are subscribing to it, and they can also publish new events, which again will impact another set of microservices. And I would like to see it all in the End-to-end transaction details page when I click on the POST request.
But unfortunately this is not happening :(
I looked for the POST request in the Transaction Search:
You can see how "event-one" is published and how there is one micro services receiving it. But nothing else.
Now if I search for the event name, I find not only the publishing trace, but also more dependencies reflecting the events that the micro sevice published:
If I click the one above the request, then I get a more comprehensive view of the whole transaction:
But still, there is a lot of it missing here: All the SQL calls each micro service did, all the actions that microservices did when receiving events two, three and four.
And actually, all of it is available in Application Map:
Which means that all telemetry is there correctly!
Questions
- Am I doing everything correctly?
- Is there a way to show the complete chain of events in the End-To-End?
Thanks in advance