Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pavlovmilen/e46fe20c9ddd9826fd896df5583266fa to your computer and use it in GitHub Desktop.
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.
/// 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