How does Application Insights' Provider load?

55 Views Asked by At

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?

2

There are 2 best solutions below

1
cijothomas On BEST ANSWER

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.

4
RithwikBojja On

When you enable application insights as below:

enter image description here

Then:

enter image description here

Or it can be enabled while creating the service:

enter image description here

Then by default the settings(connection string/instrumentation key) related to application insights are created automatically like below after enabling:

enter image description here

  • Because of this it will automatically send logs of the app service to Application insights service.
  • If there is no logging in your code or you haven't used any sdk, the logs of code will not be logged but the other logs of the app service will be logged.
  • Then it means it is connected to application insights resources and it sends the logs automatically to that application insights resource. If you are using locally the app, SDK's then you need app insights connection string to be given.