App Insights: Telemetry by version

Application Insights offers an extensibility point which allows us to inject our own modifiers to the information which is passed along.

I assume you've already got ApplicationInsights plugged into your application. There's plenty of guides on getting started available.

First step, we need to create an IContextInitializer that's going to add our current application version to the TelemetryContext.

public class VersionTelemetry : IContextInitializer  
    public void Initialize(Microsoft.ApplicationInsights.DataContracts.TelemetryContext context)
        context.Component.Version = MyApp.Version;

Next, we just need to add this to the list of ContextInitializers, when your app boots up, add:

    TelemetryConfiguration.Active.ContextInitializers.Add(new VersionTelemetry());

What about other information besides versioning?

Because application version is probably one of the most common bits of additional information you're likely to tag, it has it's own version property on the TelemetryContext. It's also exposed via the Application Insights web UI in such a way that allows you to easily filter on different versions.

Any supplemental information you'd like to provide however can also be passed along via the Properties dictionary.

context.Properties["SomeKey"] = "SomeValue";  

OK, so how do I use it?

You can inspect the application version for any telemetry data that has been logged, by clicking the elipsis to gain additional information:

Which will display (among other things):

You can also group by the different versions of your application:

Finally, you can filter all your data by just a specific version:

comments powered by Disqus