Deploy the APM Dotnet Agent
On successfully provisioning the APM Dotnet agent, you can deploy the APM Dotnet agent.
To deploy the APM Dotnet agent on any application, you need to add a set of environment variables before starting the application.
You can deploy the APM Dotnet agent on the following applications:
Deploy on Windows Service
Here's information on how to deploy the APM Dotnet agent on Windows service.
- Prepare the environment variables to deploy the APM Dotnet agent.
Review the following environment variables that are needed for deploying APM Dotnet agent:
COR_ENABLE_PROFILING=1 COR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318} COR_PROFILER_PATH_64=<destination>\win-x64\OpenTelemetry.AutoInstrumentation.Native.dll COR_PROFILER_PATH_32=<destination>\win-x86\OpenTelemetry.AutoInstrumentation.Native.dll CORECLR_ENABLE_PROFILING=1 CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318} CORECLR_PROFILER_PATH_64=<destination>\win-x64\OpenTelemetry.AutoInstrumentation.Native.dll CORECLR_PROFILER_PATH_32=<destination>\win-x86\OpenTelemetry.AutoInstrumentation.Native.dll DOTNET_ADDITIONAL_DEPS=<destination>\AdditionalDeps DOTNET_SHARED_STORE=<destination>\store DOTNET_STARTUP_HOOKS=<destination>\net\OpenTelemetry.AutoInstrumentation.StartupHook.dll ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper OTEL_DOTNET_AUTO_HOME=<destination> OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES=OpenTelemetry.ODP OTEL_SERVICE_NAME=<service-name> OTEL_LOGS_EXPORTER=none OTEL_DOTNET_AUTO_EXCLUDE_PROCESSES=dotnet.exe,dotnet OTEL_EXPORTER_OTLP_ENDPOINT=<data-upload-endpoint>/20200101/opentelemetry OTEL_EXPORTER_OTLP_HEADERS=Authorization=dataKey <private-data-key>
The following must be replaced with the correct values:
Name Description <destination> The destination directory in which the APM Dotnet Agent is provisioned. For example: C:\tracer-home
<service-name> The name of the service being monitored. This enables you to filter by service and view traces in the Trace Explorer user interface.
For example: apm_service
<data-upload-endpoint> The dataUploadEndpoint URL that is generated when the APM domain is created. For example: https://dataUploadEndpoint.com
<private-data-key> The agent installation key used by the APM Dotnet agent (private dataKey), which is generated when the APM domain is created. For example: IMWJ5UN2C
Note
For information about the data upload endpoint and private data keys, see Obtain Data Upload Endpoint and Data Keys.
- Add the environment variables to the Windows Registry.
- Backup the Windows registry before deploying APM Dotnet
agent.
For information, see How to Backup and Restore the Registry in Windows.
- Open RegistryEditor.
Select Start, type
regedit.exe
in the search box, and then press Enter. - Navigate to
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
. - Select the target service under
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
. - On the right hand panel, look for
Environment
under the Name column.- If
Environment
does not exist, create a newMulti-String Value
, name it asEnvironment
, then add environment variables prepared in step 1 to the value data. - If
Environment
exists, append environment variables prepared in step 1 to the value data.
- If
- Backup the Windows registry before deploying APM Dotnet
agent.
- Restart the Windows service.
On Windows Services UI, restart Windows service.
If you are deploying APM Dotnet agent on IIS, you do not need to restart Windows service since there's already a step to restart the IIS server.
Deploy on IIS Server
Here's information on how to deploy the APM Dotnet agent on IIS Server.
- Deploy on Windows service W3SVC.
For instructions, see Deploy on Windows Service using the Windows service name: W3SVC.
- Deploy on Windows service WAS.
For instructions, see Deploy on Windows Service using the Windows service name: WAS.
- Restart IIS.
Open Powershell as administrator, then run the command
iisreset
.
Deploy on Console Application
Here's information on how to deploy the APM Dotnet agent on Console Application.
- Prepare the environment variables to deploy the APM Dotnet agent.
Review the following environment variables that are needed for deploying APM Dotnet agent for console application:
set COR_ENABLE_PROFILING=1 set COR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318} set COR_PROFILER_PATH_64=<destination>\win-x64\OpenTelemetry.AutoInstrumentation.Native.dll set COR_PROFILER_PATH_32=<destination>\win-x86\OpenTelemetry.AutoInstrumentation.Native.dll set CORECLR_ENABLE_PROFILING=1 set CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318} set CORECLR_PROFILER_PATH_64=<destination>\win-x64\OpenTelemetry.AutoInstrumentation.Native.dll set CORECLR_PROFILER_PATH_32=<destination>\win-x86\OpenTelemetry.AutoInstrumentation.Native.dll set DOTNET_ADDITIONAL_DEPS=<destination>\AdditionalDeps set DOTNET_SHARED_STORE=<destination>\store set DOTNET_STARTUP_HOOKS=<destination>\net\OpenTelemetry.AutoInstrumentation.StartupHook.dll set ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper set OTEL_DOTNET_AUTO_HOME=<destination> set OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES=OpenTelemetry.ODP set OTEL_SERVICE_NAME=<service-name> set OTEL_LOGS_EXPORTER=none set OTEL_DOTNET_AUTO_EXCLUDE_PROCESSES=dotnet.exe,dotnet set OTEL_EXPORTER_OTLP_ENDPOINT=<data-upload-endpoint>/20200101/opentelemetry set OTEL_EXPORTER_OTLP_HEADERS=Authorization=dataKey <private-data-key> set ENABLE_BACKGROUND_ODP=true set ENABLE_CONNECTION_ODP=true
The following must be replaced with the correct values:
Placeholder Description <destination> The destination directory in which the APM Dotnet Agent is provisioned. For example: C:\tracer-home
<service-name> The name of the service being monitored. This enables you to filter by service and view traces in the Trace Explorer user interface.
For example: apm_service
<data-upload-endpoint> The dataUploadEndpoint URL that is generated when the APM domain is created. For example: https://dataUploadEndpoint.com
<private-data-key> The agent installation key used by the APM Dotnet agent (private dataKey), which is generated when the APM domain is created. For example: IMWJ5UN2C
Note
For information about the data upload endpoint and private data keys, see Obtain Data Upload Endpoint and Data Keys.
- Run the Console Application.
-
Open a command prompt.
-
Set the environment variables from step 1 in the command prompt.
-
In the same command prompt, run your console application.
-