ITelemetryProcessor breaks dependency tracking

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


ITelemetryProcessor breaks dependency tracking



I have set up a custom ITelemetryProcessor for my .NET Core 2.1 Web API. I do not want HTTP status codes 400 or 401 to be displayed as error in Application Insights. The following class does this, but as soon as I use it SQL and HTTP client dependency tracking will no longer work:



ApplicationInsights400IsOkProcessor


public class ApplicationInsights400IsOkProcessor : ITelemetryProcessor {

private ITelemetryProcessor Next { get; set; }


/// <summary>
/// Link processors to each other in a chain.
/// </summary>
/// <param name="next"></param>
public ApplicationInsights400IsOkProcessor(ITelemetryProcessor next) {
this.Next = next;
}

/// <summary>
/// API Aufrufe mit Rückgabecode 400 und 401 sind keine Fehler
/// </summary>
/// <param name="item">Telemetry zum Verarbeiten</param>
public void Process(ITelemetry item) {
var requestTelemetry = item as RequestTelemetry;
if (requestTelemetry == null) return;
bool parsed = Int32.TryParse(requestTelemetry.ResponseCode, out int code);
if (!parsed) return;
switch (code) {
case 400:
requestTelemetry.Success = true;
requestTelemetry.Context.Properties["Overridden400"] = "true";
break;
case 401:
requestTelemetry.Context.Properties["Overridden401"] = "true";
requestTelemetry.Success = true;
break;
}

this.Next.Process(item);
}



With .NET Core 2.0 I used a custom ITelemetryInitializer like this sample from Microsoft:
https://docs.microsoft.com/en-us/azure/application-insights/app-insights-api-filtering-sampling#add-properties-itelemetryinitializer



This was used by adding the following to Configure Services():


TelemetryConfiguration.Active.TelemetryInitializers
.Add(new MyTelemetryInitializer());



In .NET Core 2.1 this does not seem to work anymore









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

C# - How to create a semi transparent or blurred backcolor on windows form

Swipe gestures in WKWebView

How to populate data on nav-tab in partial View in MVC?