Reputation: 457
I've written a small Telemetry Processor to filter out some HTTP 404 which are not an issue for my application. I've been following Microsoft's doc on this process.
I have created a new class implementing ITelemetryProcessor and setup the constructor and process function.
namespace My_App
{
class WebJobQueuesDependencyFilter : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
// Link processors to each other in a chain.
public WebJobQueuesDependencyFilter(ITelemetryProcessor next)
{
this.Next = next;
}
public void Process(ITelemetry item)
{
var request = item as RequestTelemetry;
if (request != null &&
request.ResponseCode.Equals("404", StringComparison.OrdinalIgnoreCase))
{
// To filter out an item, just terminate the chain:
return;
}
// Send everything else:
this.Next.Process(item);
}
}
}
I have also added a new line to my ApplicationInsights.config under <TelemetryProcessors>
<Add Type="My_App.WebJobQueuesDependencyFilter, My_App" />
Upon starting my program I see the following message recorded in AI in Visual Studio.
AI: ApplicationInsights configuration file loading failed. Type 'My_App.WebJobQueuesDependencyFilter, My_App' was not found. Type loading was skipped. Monitoring will continue.
I suspect the issue lies with the line in config. Microsoft's docs don't seem to detail exactly what that line should contain. My guess based on MS example is the namespaced path to the filter class and the namespace for my application.
Upvotes: 2
Views: 2822
Reputation: 457
It turns out my problem was two parts.
The way I was declaring my telemetry processor was incorrect and degant's answer corrected that.
The second issue I found was that a custom telemetry processors' Process method will never be called unless you have InstrumentationKey
set in your config. Leaving it blank while developing locally won't work.
There was an issue on the Application Insights Github for this which has been resolved.
Upvotes: 5
Reputation: 4981
You probably forgot to mark the class public
so the type isn't being found. Update your telemetry processor as public
:
public class WebJobQueuesDependencyFilter : ITelemetryProcessor
Also, the correct way to specify the type includes the fully qualified name of your telemetry processor followed by the assembly name. So in your example the assembly name must be My_App
<!-- Fully qualified type name, assembly name: -->
<Add Type="My_App.WebJobQueuesDependencyFilter, My_App" />
Hope this helps!
Upvotes: 5