Johnny5
Johnny5

Reputation: 6882

How to know if application insights telemetry client is functional?

This code execute without any errors, but obviously will not log anything in ApplicationInsights. The foobar key is not valid.

 var client = new TelemetryClient
 {
    Context = { InstrumentationKey = "foobar" }
 };

 client.TrackEvent(telemetryEvent);

I understand that it may be a good thing. I dont want my application to crash because AppInsights is not avalaible. But it would be nice to know somehow that it is not reachable, so I can do something else instead.

Possible errors that I think could append :

Some of these may be transcient (api temporary not available), but others may not (invalid api key).

Is there any way I could "test" the client to react to these cases?

Something like :

if (!client.IsAppInsightReachable)
{
  //Send an email to someone so he can check if everything is OK
}

Upvotes: 3

Views: 3800

Answers (3)

Stephan Leclercq
Stephan Leclercq

Reputation: 893

I managed to get some understanding on how the telemetry client is doing, see my own question, where I describe how I managed to detect connection problems to Application Insights:

Detecting whether or not (and why) Application Insights can send telemetry data to Azure

Upvotes: 1

John Gardner
John Gardner

Reputation: 25168

If you really wanted to do it, you probably could, but it might be a lot of work re-inventing the wheel.

you'd have to do a lot of the work yourself, implementing or wrapping things like ITelemetryChannel to do what you want.

Much of the source for the various application insights sdks are up on github:

Upvotes: 2

Amnon Shochot
Amnon Shochot

Reputation: 9386

One option would be to use Fiddler as a proxy to see whether events are being sent from the SDK. This blog describes how this can be done.

Upvotes: 0

Related Questions