Reputation: 11401
This document here shows how to track dependencies on my console app. But I would like to collect only Http dependencies by default. I would like to disable the collection of SQL Server dependencies and others. How can I do that?
Upvotes: 0
Views: 123
Reputation: 6281
It is possible to filter out (and drop) what you need using Telemetry Processor.
Something like this:
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
public class DependencyFilter : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
// next will point to the next TelemetryProcessor in the chain.
public DependencyFilter(ITelemetryProcessor next)
{
this.Next = next;
}
public void Process(ITelemetry item)
{
// To filter out an item, return without calling the next processor.
if (!OKtoSend(item)) { return; }
this.Next.Process(item);
}
// Example: replace with your own criteria.
private bool OKtoSend (ITelemetry item)
{
var dependency = item as DependencyTelemetry;
if (dependency == null) return true;
return dependency.Type.Contains("HTTP");
}
}
Upvotes: 2