当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - 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 :

  • The api is not reachable
  • The event is malformed
  • the api key is invalid
  • etc.

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

}

网友答案:

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:

网友答案:

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.

网友答案:

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: