We are having a bunch of problems (read long response times) with a couple of projects in production and wanted to see exactly what was happening on the server. I then proceeded to add Application Insights to all of our projects by following this article. The problem is that both of our WebAPI projects are not sending server data to the Azure portal, while all other projects (MVC 5) are.
This is what is shown when I access the corresponding Application Insights blade on Azure:
I tried to disable and re-enable data collection in the Application Insights Status Monitor in our Azure VMs, restarted IIS a few times all while making requests to the API, to no avail. When I enable it on a MVC project, I can see the data almost instantly on the Azure portal when I open pages on the site.
When I saw that data was not being sent from our Azure VMs for these specific projects, I tried to setup the same collections in our dev environment, which is hosted in our own infrastructure, and the exact same situation repeated itself, ruling out the possibility that this is related to projects being hosted in Azure VMs.
I'm not exactly sure what is preventing these projects from sending data to Azure, but by taking a look at the working projects vs the non working ones, I think it might be somehow related to the fact that our WebAPI projects use the new OWIN pipeline while the MVC ones are standard MVC projects. I checked both the web.config file and the bin folder for both project types and they seem to be modified correctly by the Insights Monitor (I can see the same new dlls added to the bin folder and the same http module added to the web.config).
With that in mind, how do I enable server side telemetry using Application Insights for WebAPI projects that rely on the OWIN/Katana pipeline? What could I do to find out what exactly is causing the project to not send data to Azure in this case?
This is an old question but it was still in the top 3 results on searches for "web api application insights owin". After lots of searching and not a lot of answers that didn't require us to write our own middleware or explictly instrumenting everything. We came across an extension package that made things super simple:
Here's the Github Repository for it and the associated NuGet Package
For those too lazy to look at the links, all that was needed to be added was:
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseApplicationInsights();
// rest of the config here...
}
}
and add this to your ApplicationInsights.Config
<TelemetryInitializers>
<!-- other initializers.. -->
<Add Type="ApplicationInsights.OwinExtensions.OperationIdTelemetryInitializer, ApplicationInsights.OwinExtensions"/>
</TelemetryInitializers>