Last active
September 20, 2019 21:44
-
-
Save Swimburger/03987eb409b22d9384f3545b158dd14a to your computer and use it in GitHub Desktop.
ITelemetryProcessor for Application Insights to filter out Umbraco's ping requests, learn more at https://swimburger.net/blog/umbraco/ignoring-umbraco-ping-from-azure-application-insights
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
using Microsoft.ApplicationInsights.Channel; | |
using Microsoft.ApplicationInsights.DataContracts; | |
using Microsoft.ApplicationInsights.Extensibility; | |
using System; | |
namespace YourApp.ApplicationInsights | |
{ | |
public class PingFilter : ITelemetryProcessor | |
{ | |
//next processor in the pipeline | |
private readonly ITelemetryProcessor next; | |
public PingFilter(ITelemetryProcessor next) | |
{ | |
//store next processor in the pipeline | |
this.next = next; | |
} | |
//our logic goes here | |
public void Process(ITelemetry telemetry) | |
{ | |
//check to see if telemetry is for a Request | |
var request = telemetry as RequestTelemetry; | |
//ignore if RequestTelemetry is a ping request | |
if (request?.Url?.AbsolutePath.Equals("/umbraco/ping.aspx", StringComparison.OrdinalIgnoreCase) == true) | |
{ | |
//stop pipeline | |
return; | |
} | |
//invoke next processor | |
next.Process(telemetry); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment