open-telemetry / opentelemetry-dotnet-instrumentation

OpenTelemetry .NET Automatic Instrumentation

Home Page:https://opentelemetry.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IIS .NET FX Application Filter

RassK opened this issue · comments

What

When user has multiple IIS apps, they want to opt into / out of instrumentation one by one.
Currently in .NET Framework it's not possible to disable selected IIS apps, which causes issues if some are crashing. So they want to fix them one by one.

Proposal

Add OTEL_DOTNET_AUTO_EXCLUDE_APPDOMAINS / OTEL_DOTNET_AUTO_INCLUDE_APPDOMAINS filter to the native part. So bootstrapping is cancelled in very early stage.

(.NET Core apps can use properly scoped env CORECLR_ENABLE_PROFILING)

@zacharycmontoya as CorProfiler::Initialize takes place before we have any AppDomains and IIS AppDomains have no meaningful names (/LM/W3SVC/6/ROOT-1-133446990831517538). Do you have any better idea how we can get any good meaningful identifier for IIS app at CorProfiler::Initialize stage?

Extending the PowerShell install script to target IIS application pools would solve this issue. Each app pool can have it's own set of environment variables starting with IIS 10.0:
https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/applicationpools/add/environmentvariables/

Targeting a specific app pool, and installing the libraries to a common directory instead of the GAC would solve a lot of dependency concerns.

@matt-hensley thanks for the reference. Tested it out with the whole IIS instrumented and disabled instrumentation for a single app pool. Since WS 2012 R2 is now EOL (recently), I think we do not need to worry any more about < IIS 10.

Leaving here IIS UI guide also
https://learn.microsoft.com/en-us/answers/questions/674791/how-to-set-environmentalvariable-to-the-applicatio

About GAC. The GAC is re-introduced due some issues. If I rememeber correctly, it was about strong named dlls.

SIG: May want to document also alternative approach (eg using the IIS UI).