Last active
May 5, 2021 16:49
-
-
Save pavlovmilen/e46fe20c9ddd9826fd896df5583266fa to your computer and use it in GitHub Desktop.
filters out dependencies like polling queues that are not attached to any larger operation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// filters out dependencies like polling queues that are not attached to any larger operation. | |
public class AzureDependencyFilterTelemetryProcessor : ITelemetryProcessor | |
{ | |
private readonly ITelemetryProcessor _inner; | |
public AzureDependencyFilterTelemetryProcessor(ITelemetryProcessor inner) | |
{ | |
_inner = inner; | |
} | |
public void Process(ITelemetry item) | |
{ | |
if (item is Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry dependency | |
&& dependency.Success == true | |
&& dependency.Context.Operation.Name == null | |
&& (dependency.Type == "Azure Service Bus" | |
|| dependency.Type == "Azure table" | |
|| dependency.Type == "Azure blob" | |
|| dependency.Type == "Azure queue")) | |
{ | |
return; | |
} | |
_inner.Process(item); | |
} | |
} | |
// in Startup.cs: | |
services.AddApplicationInsightsTelemetryProcessor<AzureDependencyFilterTelemetryProcessor>(); | |
// link https://app.pluralsight.com/guides/configure-dependency-collection-in-apps-using-insights-sdk-for-.net-in-azure | |
// and https://docs.microsoft.com/en-us/azure/azure-monitor/app/api-filtering-sampling | |
// some AI queries: | |
dependencies | project ['type'] | summarize count() by ['type'] | |
dependencies | |
| where ['type'] contains "HTTP" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment