1

I would like to improve a open source data driver and integrate it to Azure Application Insights like the Sql Server, where all you have to do is add it...

Another option is to set it up like Azure Message Bus: module.IncludeDiagnosticSourceActivities.Add("Microsoft.Azure.ServiceBus");

How can I do that? Is there any documentation on the topic?

Leonardo
  • 10,737
  • 10
  • 62
  • 155
  • You likely need to create a `TelemetryModule` or at the very least some `TelemetryProcessors`/`TelemetryInitializers`. The Sql stuff works because of the `DependencyTelemetryModule` which gets configured by most AddAppInsights calls. It's open source itself so perhaps a place to start – pinkfloydx33 Jun 26 '20 at 20:27
  • it is? open source I mean... can you point me to that implementation? – Leonardo Jun 26 '20 at 20:36
  • Not now I can't. But I assure you it as I have previously dug through it in an attempt to do something similar to you. Find the Appinsight github for the Web components. It's probably archived if I recall correctly but that's where I started. – pinkfloydx33 Jun 26 '20 at 20:58
  • In fact, search all of github for `DependencyTrackingTelemetryModule` and then whittle it down to C# and in the ASP.Net repository). That's what I did. (I had a typo in the name in my original comment. I've corrected it here) – pinkfloydx33 Jun 26 '20 at 21:00

1 Answers1

1

Are you asking about instrumenting an opensource data driver library, so that when that library is used in applications that have enabled ApplicationInsights, telemetry from that data driver library shows up? If this is the case, the library needs to be instrumented with DiagnosticSource/Activity, just like other libraries (eg: SqlClient, HttpClient), and then write a module like DependencyTelemetryModule to listen to the DiagnosticSource/Activity callbacks, and convert them to ApplicationInsights model.

Doc explaining the instrumentation side: https://github.com/dotnet/runtime/blob/master/src/libraries/System.Diagnostics.DiagnosticSource/src/ActivityUserGuide.md

Actual code showing how HttpClient is intrumented: https://github.com/dotnet/runtime/blob/master/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs

(Disclaimer: I work in Application Insights team. And also as part of .NET/OpenTelemetry. There a fairly big shift in the guidance on how to instrument libraries. It still uses Activities, but in a different way. The new guidelines are not published anywhere officially, it'll be done by .NET 5 timeframe ~Nov 2020)

Is this what you were looking for?

cijothomas
  • 2,818
  • 1
  • 13
  • 25