Tracking SQL dependencies with Application Insights (without installing the agent!)

Av Peter Örneholm | Blogg | 11 november 2015

1/5 2016 Update: Nowadays (not sure what exact version it was introduced in) you dont need either the agent or the code below if you are running and targeting .NET 4.6. If you are using .NET 4.6 you will be able to collect for “all” outgoing SQL connections. So, upgrade to .NEt 4.6 and skip the stuff below :) Read more at:

In some projects where we use Azure Application Insights we are not able to install the agent in our production systems. The agent, if installed, will track call to remote dependencies such as HTTP and SQL Servers. Though, we are really interested in the time it takes to call our SQL servers so I started exploring alternative ways of doing this.

So, what I’ve done is basically to write an interceptor for Entity Framework (as this is our ORM we use most) that will intercept each call made and simulate the same tracking that would be done through the agent (or at least they way I’ve understood it does the tracking). It uses TelemetryClient.trackDependency() to do this, an API available in the latest SDK.

Fell free to use it and provide feedback of ways to improve :)

Till inlägget