Unable to get Application Insights to show debugging telemetry

别来无恙 提交于 2019-12-11 18:47:30

问题


I am a total noob with Application Insights, and sadly for a whole day of trying I have been unable to get it working at all. I tried with the following code:

this.telemetryClient = new TelemetryClient(TelemetryConfiguration.CreateDefault());
this.telemetryClient.TrackTrace($"Test", Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Warning);

But when I go to the application insights window and show all telemetry from the current debugging session there is nothing logged. One user said an ApplicationInsights.config file is missing (and that an empty one would do fine for debugging), I created one but it changed nothing.

Then I tried the simplest console app I could find - https://docs.microsoft.com/en-us/azure/azure-monitor/app/console . I don't have an instrumentation key, and from the hundreds of forums I read today, if you leave it blank it should still appear in the debugging telemetry. Alas, still nothing in Application Insights.

How can I get it working? I just want to see a single Trace message in the Visual Studio Application Insights window when queried for "debugging telemetry".


回答1:


I used to work on this stuff and the way it generally works, the extension tries to figure out if it should watch for debug output, and if it doesn't recognize the project type, we do nothing (to avoid doign work in the debugger when we don't need to). in this case, console apps aren't a "known" supported project type.

IIRC, to get debug output I believe you need to do 2 things, of which you've done 1:

1) add an ApplicationInsights.config file at the root of that project

2) add an application insight resource id to to the csproj:

 <ApplicationInsightsResourceId>/subscriptions/abc</ApplicationInsightsResourceId>

i don't think the resource id even needs to be valid, but if it does even better, because then other things can light up, like exceptions codelens, various links to the portal/etc.

you migth only need to do #2?

i think that if you do the above and restart vs/reload the solution, you should see the debugger integration try to do work when the debugger starts. (it used to!)



来源:https://stackoverflow.com/questions/58307327/unable-to-get-application-insights-to-show-debugging-telemetry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!