<private-data-key>: The agent installation key used by APM Dotnet agents (private dataKey) which is generated when the APM domain is created. For information, see Obtain Data Upload Endpoint and Data Keys.
<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.
You can add more environment variables if needed. For example, if you need to configure browser agent injection or abridged trace. The environment variable name should use the prefix $env: and the environment variable value should be quoted by double quotes "".
Best Practice: Run clear-history after deploying the APM .NET agent. This cleans up sensitive data such as private data key from the PowerShell history.
Optional - Register .NET Framework DLLs in GAC.
This step is only required by .NET framework applications. If you do not have .NET framework application, skip this step.
To register .NET framework DLLs in GAC, do the following:
Register-OpenTelemetryDllsToGac
Deploy the APM Dotnet agent.
Deploy the APM Dotnet agent on the following applications:
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 OTEL_DOTNET_ENABLE_BACKGROUND_ODP=true
set OTEL_DOTNET_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.
Configure additional environment variables by running the following script:
. $OTEL_DOTNET_AUTO_HOME/instrument.sh
Run the application.
Open a shell session.
Set environmental variables from step 1 and step 2 in the shell session.
In the same session, run your application.
Deploy the APM Dotnet Agent in
Kubernetes using OpenTelemetry Operator 🔗
Here's information on how to deploy an APM Dotnet agent using the
OpenTelemetry operator to automatically inject and configure the APM Dotnet agent into your
Dotnet application pods on Kubernetes (K8s) clusters.
You can use the APM Dotnet agent to monitor Dotnet applications. The
OpenTelemetry operator is used to deploy the APM Dotnet agent and is an implementation of a
K8s operator providing an easy way to automatically inject Dotnet agents to Dotnet
applications running on K8s pods.
To deploy the APM Dotnet agent, follow these steps:
Create a Kubernetes Custom Resource (CR).
To manage automatic
instrumentation, the OpenTelemetry Operator needs to be provided with information about
the APM Dotnet agent and its configuration which it's done using the Custom Resource Definition
(CRD).
This Custom Resource will be used by the operator to copy the
agent into the pod and add to it the required configuration.
Run the
following command to create the CR on your Kubernetes
cluster:
<data-upload-endpoint> is the data upload endpoint URL
that is generated when the APM domain is created. For information, see Obtain Data Upload Endpoint and Data
Keys.
<private-data-key> is the APM Dotnet agent installation
private data key which is generated when the APM domain is created. For information,
see Obtain Data Upload Endpoint and Data
Keys.
The created CR can be queried by running the following
command:
kubectl get otelinst -n opentelemetry-operator-system
All endpoints and environment variables required to be correct for auto-instrumentation
to work properly.
Add the Kubernetes annotation.
The OpenTelemetry operator uses
Kubernetes annotation to decide which pods should be auto-injected with the APM Dotnet
agent.
The annotation can be added to a namespace. In that case, all
the pods within that namespace will get injected. The annotation can also be added to
individual PodSpec objects, available as part of Deployment, Statefulset, and other
resources.