Search code examples
azure-application-insights

How does Application Insights' Provider load?


I am using Application Insights for a Web Service in Azure, and I have configured it using the "Application Insights" panel under "Settings".

Even though I haven't added any code specifically to use "OpenTelemetry" or "Application Insights SDK", it still somehow knows to use the Application Insights connection string and send log data there.

The only theory I have is that it is using EventSource as the logging provider, but some other process is picking up the logging data and sending it to Application Insights.

How does it actually work without any code being added?


Solution

  • There is no "magic" there! WebApps has the concept of Extensions, and Application Insights is one such extensions, pre-installed in every AppService instances. When the portal setting is enabled, all it does underneath is set some AppSettings, triggering/activating the extensions. The Application Insights extension itself leverages facility provided by the language/runtime to inject things to a pre-compiled. For .NET, "startup hooks" - https://github.com/dotnet/runtime/blob/main/docs/design/features/host-startup-hook.md and related techniques are used. Java uses bytecode instrumentation. Some versions of .NET extensions uses a different technique.