Reputation: 68
I'm currently using App insights for logging exceptions and tracing. My project is Asp.net MVC based and I've 3 different layers. One is front end (MVC with angular) and rest two are Web API service layers. I've default telemetry logging enabled for all the 3 layers and it is logging all the operations.My problem is that I'm not able to correlate the operation on all the 3 layers. How can I achieve this. I've read that one option is to set the custom property (userID in session) on Telemetry Initializer , but I don't have that information on my Web API layers as they are stateless.
Upvotes: 0
Views: 893
Reputation: 13859
Besides the already mentioned alternatives, there's already partial support for this built into AI through the ParentOperationId and OperationId context fields. However, there's nothing in place right now that can propagate the fields through Http calls automatically.
It should be possible to have your code add the necessary headers when making outgoing HTTP calls and if you use the right ones, and the other side has the necessary telemetry initializers, it should be better.
Upvotes: 1
Reputation: 554
One solution I can think about:
You can generate an internal identifier (e.g. a GUID) for each operation in your MVC layer, add it as a custom parameter (using the Telemetry Initializer) and pass that same ID to the Web API layers for each API call you make. For every telemetry event these Web API layers send, add the identifier as a custom parameter in the same fashion as above.
This way you will be able to correlate the events based on your internal ID.
Upvotes: 2