1
votes

I'm trying to retrofit Application Insights into an existing app but no matter what I do, I can only seem to get telemetry back from the front end:

Application Insights dashboard

(note "Add Application Insights SDK..." banner, "No data" warning, apparently 0ms for all server responses and 0 server requests - the little blue semi-circle on server response times is just the current selected point)

I've installed v2.1.0 of the following nuget packages:

"Microsoft.ApplicationInsights"
"Microsoft.ApplicationInsights.Agent.Intercept"
"Microsoft.ApplicationInsights.DependencyCollector"
"Microsoft.ApplicationInsights.NLogTarget"
"Microsoft.ApplicationInsights.PerfCounterCollector"
"Microsoft.ApplicationInsights.Web"
"Microsoft.ApplicationInsights.WindowsServer"
"Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel"

and added my instrumentation key to the ApplicationInsights.config file:

  <InstrumentationKey>{my key here}</InstrumentationKey>
</ApplicationInsights>

I've also monitored the events going through ETW and I see plenty of messages suggesting that data is getting logged although there are also quite a lot of messages saying:

WebTelemetryInitializerNotExecutedOnNullHttpContext

but not sure if that's a problem or not?

To confuse things a little further, some server-side data does seem to be getting through since the application map looks like this:

Application Map

I've also tried installing the Application Insights Agent on the box, but that made absolutely no difference that I could see!

There appear to be a number of similar questions out there, but they all seem to have no resolution, the resolution is to remove and re-add the nuget packages (tried) or there were multiple ApplicationInsights.config files (checked and there aren't)...

N.B. this app is usually running on a VM in AWS EC2, but there are no firewall rules blocking any outbound traffic and I've also tried running it locally...

3

3 Answers

0
votes

Yes, the problem is the WebTelemetryInitializerNotExecutedOnNullHttpContext message you found. Looking at the source code, this means that the HttpContext.Current is null.

I'm not sure why this is happening in your case, so can you please elaborate on your web app structure? Are you running IIS on the VM?

0
votes

Got it working, but can't really explain.

Started again from scratch, and this time it worked, even though my initial attempt and starting from scratch last time didn't.

I noticed that there are some new features such as integration with Code Lens, so I don't know if something changed in Application Insights, or something went wrong twice in a row (though I don't know what could have gone wrong since adding Application Insights is not really a complicated process!)

0
votes

For ASP.NET projects please also consider the used azure region. There are problems with the "Germany West Central" region. It does not synchronizes all data to azure application insights. We solved our problem by switching the aplication insights azure instance to the region "Europe West" (We had no problems with ASP.NET CORE projects).

I have no idea why MS does not mention this fact, but after hours of searching we found the following github entry -> https://github.com/microsoft/ApplicationInsights-dotnet/issues/1931