|
| 1 | +.. _advanced-config-iis-apps: |
| 2 | + |
| 3 | +******************************************* |
| 4 | +Advanced configuration for IIS applications |
| 5 | +******************************************* |
| 6 | + |
| 7 | +Follow these advanced configuration steps to make changes to specific application pools. |
| 8 | + |
| 9 | +Set environment variables |
| 10 | +========================= |
| 11 | + |
| 12 | +You can set environment variables for specific application pools in the ``environmentVariables`` block of the :new-page:`applicationHost.config file <https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/applicationpools/add/environmentvariables/#configuration-sample>`. |
| 13 | + |
| 14 | +For example: |
| 15 | + |
| 16 | +.. code-block:: xml |
| 17 | +
|
| 18 | + <environmentVariables> |
| 19 | + <add name="OTEL_RESOURCE_ATTRIBUTES" value="deployment.environment=test,service.version=1.0.0" /> |
| 20 | + </environmentVariables> |
| 21 | +
|
| 22 | +For all IIS applications, consider setting common environment variables for W3SVC and WAS Windows Services. For more information, see :new-page:`Instrument a Windows Service running a .NET application <https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/blob/main/docs/windows-service-instrumentation.md>` in the OpenTelemetry documentation. |
| 23 | + |
| 24 | +.. note:: |
| 25 | + |
| 26 | + If the same environment variables are set in the ``environmentVariable`` block and in the web.config ``appSettings`` block, the value in the ``environmentVariables`` block takes precedence. |
| 27 | + |
| 28 | +Activate or deactivate instrumentation |
| 29 | +====================================== |
| 30 | + |
| 31 | +For .NET Framework applications, use the PowerShell module to activate or deactivate the instrumentation for specific application pools. |
| 32 | + |
| 33 | +#. Import the PowerShell module: |
| 34 | + |
| 35 | + .. code-block:: powershell |
| 36 | +
|
| 37 | + Import-Module "OpenTelemetry.DotNet.Auto.psm1" |
| 38 | +
|
| 39 | + .. note:: |
| 40 | + |
| 41 | + The application pool name is case sensitive. |
| 42 | + |
| 43 | +#. Activate or deactivate the application pool. |
| 44 | + |
| 45 | + * Activate instrumentation for the application pool: |
| 46 | + |
| 47 | + .. code-block:: powershell |
| 48 | +
|
| 49 | + Enable-OpenTelemetryForIISAppPool -AppPoolName <app-pool> |
| 50 | +
|
| 51 | + * Deactivate instrumentation for the application pool: |
| 52 | + |
| 53 | + .. code-block:: powershell |
| 54 | +
|
| 55 | + Disable-OpenTelemetryForIISAppPool -AppPoolName <app-pool> |
| 56 | +
|
| 57 | +#. Restart the application pool: |
| 58 | + |
| 59 | + .. code-block:: powershell |
| 60 | +
|
| 61 | + Restart-WebAppPool -Name <app-pool> |
0 commit comments