Sergey # Blog

Few thoughts about the current.

LINQ to Application Insights Live Session

When working with ApplicationInsights you sometimes need to see whether data is sent out. For that purposes you can use Fiddler.

But also sometimes you want to filter that data, find some specific events or metrics, from certain users or with certain customer properties.

With Tx.ApplicationInsights.Session nuget you can create a live session and run LINQ queries to filter data.

Here is the example:

For 0.13 - 0.14.1 SDK:

1
2
3
  <TelemetryChannel>
    <EndpointAddress>http://localhost:1234/</EndpointAddress>
  </TelemetryChannel>

For 0.14.1 and later

1
2
3
  <TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.PersistenceChannel, Microsoft.ApplicationInsights.PersistenceChannel">
    <EndpointAddress>http://localhost:1234/</EndpointAddress>
  </TelemetryChannel>
  • Add and run this code in LinqPad:
1
2
3
4
5
6
7
8
9
var playback = new Playback();

playback.AddApplicationInsightsSession("http://localhost:1234/");

playback
  .GetObservable<Envelope<RequestData>>()
  .Dump();

playback.Start();   

or add and run this code in regular console application. Make sure that the following namespaces are being added: System.Reactive, Tx.ApplicationInsights.Session and Tx.ApplicationInsights.Session.TelemetryType.

  • Start your sample application. When it starts generating request telemetry you will see requests being logged in LinqPad/Console Application.

Your application will send data to http://localhost:1234/ so you can inspect it but data will not be forwarded to your AI production endpoint.

Now you can modify this example to filter data using regular LINQ.

Currently the library supports all 10 ApplicationInsights telemetry types (They all are in Tx.ApplicationInsights.Session.TelemetryType namespace).

Comments