Set of Telemetry Processors and Initializers useful to extend Telemetry Collection with Application Insights.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md

README.md

ApplicationInsightsTelemetryExtensions

Overview

Application Insights has the ability to extend the telemetry collection processs with TelemetryInitializers and TelemetryProcessors

https://docs.microsoft.com/en-us/azure/application-insights/app-insights-api-filtering-sampling

These extensions allow you to better manage your telemetry by adding to it, or filtering out unwanted collection. This collection is a set of Telemetry Processors and Initializers useful to extend Telemetry Collection with Application Insights.

Installation

  1. Add a reference to the NuGet package:

    dotnet add package ApplicationInsightsTelemetryExtensions
  2. Restore NuGet package:

    dotnet restore
  3. Add TelemetryProcessor

ASP.NET Framework (AppStart in Global.asax)

protected void Application_Start()
{
   // ...
   var builder = TelemetryConfiguration.Active.TelemetryProcessorChainBuilder;
   builder.Use((next) => new SuccessfulDependencyFilter(next));

   // If you have more processors:
   builder.Use((next) => new AnotherProcessor(next));
   builder.Build();
}

ASP.NET Core (Startup.cs)

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    var configuration = app.ApplicationServices.GetService<TelemetryConfiguration>();
    configuration.TelemetryProcessorChainBuilder
                        .Use(next => new BotRequestTracking(next))
                        .Build();
}
  1. Add TelemetryInitializer

ASP.NET Framework (AppStart in Global.asax)

 protected void Application_Start()
 {
     // ...
     TelemetryConfiguration.Active.TelemetryInitializers
     .Add(new MyTelemetryInitializer());
 }

ASP.NET Core (Startup.cs)

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    var initializer = new SuccessfulDependencyFilter();
    var configuration = app.ApplicationServices.GetService<TelemetryConfiguration>();
    configuration.TelemetryInitializers.Add(initializer);
}

Acknowledgements

Some of these I came up with myself, others I collected from some amazing blog posts.