-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine setup and configuration docs (#2082)
- Loading branch information
Showing
5 changed files
with
92 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,4 @@ ASPNETCORE | |
HOSTINGSTARTUPASSEMBLIES | ||
Bootstrapper | ||
NETFX | ||
iisreset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,46 @@ | ||
# Instrument a Windows Service running a .NET application | ||
|
||
We recommend setting environment variables for a Windows Service | ||
using the Windows Registry. | ||
## Setup | ||
|
||
> Remember to restart the Windows Service | ||
after making changes to its configuration. | ||
Use the `OpenTelemetry.DotNet.Auto.psm1"` PowerShell module | ||
to set up automatic instrumentation for a Windows Service: | ||
|
||
## Set environment variables for a Windows Service | ||
```powershell | ||
# Import the module | ||
Import-Module "OpenTelemetry.DotNet.Auto.psm1" | ||
# Install core files | ||
Install-OpenTelemetryCore | ||
# Set up your Windows Service instrumentation | ||
Register-OpenTelemetryForWindowsService -WindowsServiceName "WindowsServiceName" -OTelServiceName "MyServiceDisplayName" | ||
``` | ||
|
||
⚠️ `Register-OpenTelemetryForWindowsService` performs a service restart. | ||
|
||
## Configuration | ||
|
||
> Remember to restart the Windows Service after making configuration changes. | ||
> You can do it by executing | ||
> `Restart-Service -Name $WindowsServiceName -Force` in PowerShell. | ||
For .NET Framework applications you can configure the most common `OTEL_` settings | ||
(like `OTEL_RESOURCE_ATTRIBUTES`) via `appSettings` in `Web.config`. | ||
|
||
The alternative is to set environment variables for the Windows Service | ||
in the Windows Registry. | ||
|
||
The registry key of a given Windows Service (named `$svcName`) is located under: | ||
|
||
```powershell | ||
HKLM\SYSTEM\CurrentControlSet\Services\$svcName | ||
``` | ||
|
||
The environment variables can be defined | ||
The environment variables are defined | ||
in a `REG_MULTI_SZ` (multiline registry value) called `Environment` | ||
in the following format: | ||
|
||
```env | ||
Var1=Value1 | ||
Var2=Value2 | ||
``` | ||
|
||
Below is an example demonstrating how instrumentation can be configured | ||
in PowerShell (run as administrator): | ||
|
||
```powershell | ||
$installationLocation = "C:\some\dir" # The path where you put the OTel .NET AutoInstrumentation binaries | ||
$svcName = "MySrv" # The name of the Windows Service | ||
[string[]] $vars = @( | ||
"COR_ENABLE_PROFILING=1", | ||
"COR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318}", | ||
"COR_PROFILER_PATH_64=$installationLocation\win-x64\OpenTelemetry.AutoInstrumentation.Native.dll", | ||
"COR_PROFILER_PATH_32=$installationLocation\win-x86\OpenTelemetry.AutoInstrumentation.Native.dll", | ||
"CORECLR_ENABLE_PROFILING=1", | ||
"CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318}", | ||
"CORECLR_PROFILER_PATH_64=$installationLocation\win-x64\OpenTelemetry.AutoInstrumentation.Native.dll", | ||
"CORECLR_PROFILER_PATH_32=$installationLocation\win-x86\OpenTelemetry.AutoInstrumentation.Native.dll", | ||
"DOTNET_ADDITIONAL_DEPS=$installationLocation\AdditionalDeps", | ||
"DOTNET_SHARED_STORE=$installationLocation\store", | ||
"DOTNET_STARTUP_HOOKS=$installationLocation\net\OpenTelemetry.AutoInstrumentation.StartupHook.dll", | ||
"OTEL_DOTNET_AUTO_HOME=$installationLocation", | ||
"OTEL_DOTNET_AUTO_INTEGRATIONS_FILE=$installationLocation\integrations.json", | ||
"OTEL_SERVICE_NAME=my-service-name" | ||
) | ||
Set-ItemProperty HKLM:SYSTEM\CurrentControlSet\Services\$svcName -Name Environment -Value $vars | ||
``` |