Application Insights

Application Insights is a service for web developers which helps to monitor a live web application. It automatically collects issues and telemetry of the application and sends them to the Microsoft Azure portal where the information can be analyzed.

DotVVM supports this service and tracks some additional telemetry collected during the processing of a HTTP request.

Create the Application Insights resource

In order to view telemetry data in Microsoft Azure portal you need to create a Microsoft Azure resource. This can be done either through IDE or manually.

The process of creating a new Microsoft Azure resource is described in Create an Application Insights resource page.

After the Application Insights resource is created, you will get the Instrumentation Key which will be placed in the configuration file.

Configure Application Insights

You can add Application Insights to an ASP.NET Core project using the Visual Studio Solution Explorer window, or manually.

Follow this guide: Application Insights for ASP.NET Core to add Application Insights in Visual Studio Solution Explorer.

To install Application Insights in your ASP.NET Core project manually, you need to add Microsoft.ApplicationInsights.AspNetCore NuGet package dependency.

In order to see the telemetry data in Microsoft Azure resource, you need to add the Instrumentation key to the appsettings.json file. You can find this key in the Overview tab of your Microsoft Azure resource. After that, you need to add instrumentation code to the Startup.cs class in you project.

For more information about the Application Insights configuration in ASP.NET Core project see the Getting Started with Application Insights for ASP.NET Core page.

After the Application Insights are installed, run the following command in the Package Manager Console window:

Install-Package DotVVM.Tracing.ApplicationInsights.AspNetCore

Then, register the DotVVM tracking reporter in the DotvvmStartup.cs this way:

public void ConfigureServices(IDotvvmServiceCollection options)

Collect the client-side telemetry

In both ASP.NET Core and OWIN version, you can use the ApplicationInsightsJavascript control, which renders the Application Insight JavaScript snippet to do the tracing on the client-side.

According to the official documentation, it should be placed just before </head> tag:

   <dot:ApplicationInsightsJavascript />

The OWIN version of the control contains the EnableAuthSnippet property which can collect identifiers of authenticated users.

In ASP.NET Core web apps, this value is taken from ApplicationInsightsServiceOptions configuration object.

View telemetry data in Azure portal

You can display the collected DotVVM telemetry by editing any chart in the Server request tab. You can also choose which metrics you want to track in the metrics tab under Custom drop down menu. You can also aggregate the data.

DotVVM metrics in Microsoft Azure portal

It is also possible to filter this data by the name of the operation:

Filter metrics in Microsoft Azure portal

Additionally, you can analyze exceptions that were thrown in your web application:

Exceptions in Microsoft Azure portal

See also