Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to correlate the two AI’s telemetry data of Front End calls and Web API calls using correlation feature

I had Angular2 and Asp.Net Web API applications for that I configured the Application Insights Resource for tracking custom telemetry of those applications. But I used two different AI keys, one for Angular2 application and one for Web API application.

I used to correlation feature to correlate the Two Applications Insights telemetry of Front End calls and Web API calls but operation ID did not match.

Can you please tell me how to correlate the two AI’s telemetry of Front End calls and Web API calls using correlation feature.

like image 916
Pradeep Avatar asked Jun 21 '17 13:06

Pradeep


1 Answers

Edit: Fixing per the additional information in comment.

You sound like you want to correlate the dependent requests with the server request. This is usually handled by the combination of two pieces:

  1. Set disableCorrelationHeaders = false in the JavaScript snippet config
  2. Ensure your API Service has the OperationCorrelationTelemetryInitializer added in the ApplicationInsights.config under the <TelemetryInitializers> section

The JavaScript setting will set the x-ms-request-id and the x-ms-request-root-id header to be picked up by the telemetry initializer.

The initializer relies on the HttpContext.Request being available.

Using separate instrumentation keys (iKeys) will not matter when it comes to setting the operation id. Where it will matter is when you go to look for this correlated telemetry in the UI. If everything flows to the same iKey it will be able to be retrieved.

The next thing to be mindful of is if your server side telemetry is being sampled. By default the AdaptiveSampling processor is enabled and set to only send 5 telemetry items per second.

Steps to troubleshoot

  1. When the request is sent from the browser use Fiddler or the F12 tools to ensure the x-ms-request-* headers are being set.
  2. Debug your WebAPI application and validate that System.Web.HttpContext.Current.Request.Headers["x-ms-request-id"] or System.Web.HttpContext.Current.Request.Headers["x-ms-request-root-id"] is present
  3. Ensure <Add Type="Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer, Microsoft.AI.Web"/> is added in the <TelemetryInitializers> section of your ApplicationInsights.config
  4. Increase the <MaxTelemetryItemsPerSecond> to a large number like 5000
  5. Make sure you're using v2.2.0 or higher of the .NET SDK
like image 105
James Davis - MSFT Avatar answered Oct 19 '22 22:10

James Davis - MSFT