Adding Datadog APM to .NET - Tracer and IIS Configuration
Adopting APM in .NET is the work of installing the Tracer and then delivering the environment variables that enable the profiler to the processes you want to instrument. The variable names differ between .NET Framework and .NET Core, and on IIS, while the MSI prepares the values for you, a restart that stops and starts everything including WAS is required.
.NET Instrumentation Is a Mechanism That Calls In a Profiler Through Environment Variables
The Datadog .NET Tracer inserts instrumentation into an app through the profiling API that the .NET CLR provides. The runtime tries to load the Tracer into any .NET process that starts with the designated environment variables, so the substance of adoption comes down almost entirely to "which processes you deliver the variables to." Only one profiler can be registered with this API, and the guidance is not to run it side by side with another APM product in the same app. The other caution is scope. If you set the variables for the whole OS, every .NET process on the host is instrumented, so narrow it to just the target apps (as of October 2026; source: Tracing .NET Framework Applications / Tracing .NET Core Applications).
| Owner of the process | Where to write the variables | How to apply them |
|---|---|---|
| IIS site | Already set by the MSI. Values to add go in Environment under the WAS key in the registry | net stop /y was followed by net start w3svc |
| Windows service | Environment under HKLM\System\CurrentControlSet\Services\(service name) in the registry | Restart the service |
| Console app | SET in a batch file run before startup | Start the app again |
| Linux systemd service | The file specified in EnvironmentFile | Restart the service |
| Linux Docker container | ENV in the Dockerfile | Rebuild the image and start it |
Unlike adding APM to Python, where you add a prefix at the head of the startup command, in .NET what you change is neither the code nor the startup line but the environment that the process inherits. Get the place where you write the variables wrong by just one, and even if the installation succeeded, not a single trace appears. If you first decide where your app falls in the left column of the table, the remaining steps go without hesitation.
The Two Sets, COR_ and CORECLR_, Reflect Which Runtime Reads Them
The .NET Framework CLR reads variables beginning with COR_, while .NET Core and .NET 5 and later read variables beginning with CORECLR_, so values with the same role have two sets of names. On Windows, the MSI prepares the rest of the values, so outside IIS the only one you write yourself is the one that enables profiling. On Linux, you pass all four yourself (as of October 2026; source: Tracing .NET Core Applications).
| Role | .NET Framework (Windows) | .NET Core / .NET (Windows) | .NET Core / .NET (Linux) |
|---|---|---|---|
| Enabling the profiler | COR_ENABLE_PROFILING=1 | CORECLR_ENABLE_PROFILING=1 | CORECLR_ENABLE_PROFILING=1 |
| Profiler identifier | COR_PROFILER (set by the MSI) | Set by the MSI | CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8} |
| Location of the native part | COR_PROFILER_PATH_32 and COR_PROFILER_PATH_64 (set by the MSI) | Set by the MSI | CORECLR_PROFILER_PATH=/opt/datadog/Datadog.Trace.ClrProfiler.Native.so |
| Location of the Tracer | DD_DOTNET_TRACER_HOME (set by the MSI) | Set by the MSI | DD_DOTNET_TRACER_HOME=/opt/datadog |
The Framework COR_PROFILER and the Linux CORECLR_PROFILER point to the same identifier, and the diagnostic tool's check also verifies whether it is this value. On musl-based systems such as Alpine, change CORECLR_PROFILER_PATH to a path under linux-musl-x64/. The minimum supported versions are 4.6.1 for .NET Framework and 3.1 for .NET Core (source: Tracing .NET Framework Applications / .NET and .NET Core Compatibility Requirements). The compatibility table lists the Tracer version required for each runtime version, so when you upgrade the runtime, pair it with the Tracer version and check it in the table.
On Windows, Install the MSI, and Outside IIS Pass the Variables Yourself
On Windows, run the Tracer MSI with administrator privileges and install it machine-wide. Starting with v3.0.0, there is only an x64 version, and it can instrument both 64-bit and 32-bit apps. Installing via the NuGet package Datadog.Trace.Bundle does not instrument IIS apps. For IIS, the MSI is a prerequisite (as of October 2026; source: Tracing .NET Framework Applications). For Windows services outside IIS, write the variables in the following form and then restart.
Set-ItemProperty HKLM:SYSTEM\CurrentControlSet\Services\<SERVICE NAME> -Name Environment -Value 'COR_ENABLE_PROFILING=1'What you install here is the side that creates traces; get the receiving Agent running first by following installing the Agent on Windows.
IIS Is Not Instrumented Until You Stop and Start Everything Including WAS
For IIS sites, the MSI prepares all the necessary variables, so no additional configuration is needed. In exchange, to make the instrumentation take effect, you stop IIS completely and then start it again, as an administrator, with the following two commands. The official documentation strongly cautions that restarting from the IIS Manager UI or with iisreset.exe does not work (as of October 2026; source: Tracing .NET Framework Applications / Tracing .NET Core Applications).
net stop /y was
net start w3svc- 1. Decide when to stop it - The procedure stops IIS completely and starts it again, so the sites on that server will have downtime
- 2. Write the values common to all sites - One per line in Environment at HKLM\System\CurrentControlSet\Services\WAS in the registry
- 3. Stop and start - net stop /y was followed by net start w3svc, and also start any other services that stopped along with WAS
- 4. Send one request to the site - The application pool starts only after a request arrives
- 5. Check - Verify the pool's worker process with dd-dotnet check iis, described in the next section
Values written in the WAS Environment are inherited by all sites. The examples the official documentation gives include DD_LOGS_INJECTION=true for log correlation; if you write DD_SERVICE, which you want to vary per site, here, every site gets the same name. Put per-site values in <appSettings> in each site's web.config, in the form <add key="DD_SERVICE" value="…"/>. If you do not write it, the Tracer uses the IIS application name (source: Configuring the .NET Framework SDK). If you run .NET Core or later apps on IIS, setting the pool's .NET CLR version to No Managed Code is also a requirement (source: Tracing .NET Core Applications).
On Linux and in Containers, Create the Log Location Before Starting
On Linux, install the Tracer package that matches your OS and CPU, then run /opt/datadog/createLogPath.sh to create the log location /var/log/datadog/dotnet with the appropriate permissions. This location is required before you enable debug logs, so if you skip it, the trouble comes when you want to investigate a problem (as of October 2026; source: Tracing .NET Core Applications / Tracer Debug Logs).
| OS or image | How to install |
|---|---|
| Debian / Ubuntu | Install the deb with dpkg -i and run createLogPath.sh |
| CentOS / Fedora | Install the rpm with rpm -Uvh and run createLogPath.sh |
| musl-based systems such as Alpine | Extract the musl tar.gz to /opt/datadog and run createLogPath.sh with sh |
| Other Linux | Extract the tar.gz to /opt/datadog and run createLogPath.sh |
| Chiseled images with no shell | Extract the tar.gz with ADD in the Dockerfile, and copy an empty directory with COPY --chown=$APP_UID to serve as the log location |
Write the four variables in EnvironmentFile for a systemd service, or in ENV for Docker. In Kubernetes, instead of writing them in the Pod definition, there is a way to have the SDK and destination injected when the Pod is created, and what handles that is the Cluster Agent. The behavior of the form that also leaves embedding the SDK to it is summarized in the automatic instrumentation entry.
The Conditions for the IDs That Link Logs and Traces Differ by Logger
DD_SERVICE / DD_ENV / DD_VERSION, which unify a service into one in the UI, can be used as the three of unified service tagging with the same meaning as in other languages. Where the steps diverge in .NET is log correlation. DD_LOGS_INJECTION is enabled by default starting with Tracer 3.24.0, and in earlier versions you set true explicitly (as of October 2026; source: Correlating .NET Logs and Traces).
| Logger | Condition |
|---|---|
| Serilog | v1.4 or later. From Tracer 2.0.1 onward, automatic instrumentation must be enabled |
| log4net | From Tracer 1.29.0 onward, automatic instrumentation must be enabled |
| NLog | From Tracer 2.0.1 onward, automatic instrumentation must be enabled |
| Microsoft.Extensions.Logging | Support was added in Tracer 1.28.6 |
"Automatic instrumentation must be enabled" means that if the profiler has not been loaded by the environment variables described so far, the logger-side settings alone do not insert the IDs. To receive logs containing IDs in Log Management, you separately need log collection configured on the Agent side. If you do not parse them with Datadog's log integration, prepare your own rules that extract dd.trace_id and dd.span_id as strings.
When Traces Do Not Arrive, Use dd-dotnet to See Whether the Process Received the Variables
The first thing to use when traces do not arrive is the diagnostic tool dd-dotnet. It is bundled starting with Tracer 2.42.0, placed in the installation directory and also added to the system PATH, so you can call it from anywhere. If you specify an IIS app by a name consisting of the site name followed by the app name, it examines the pool's worker process and checks, in order, the loading of the required modules, the values of the COR_ variables, and the connection to the Agent. The pool does not start until a request arrives, so access the site once before running it (as of October 2026; source: Using the .NET diagnostic tool for troubleshooting).
- 1. dd-dotnet check iis "Default Web Site/WebApplication1" - Checks one IIS app
- 2. dd-dotnet check process (PID) - Checks a process outside IIS
- 3. dd-dotnet check agent - Checks only whether it reaches the Agent
- 4. DD_TRACE_DEBUG=true - Outputs detailed logs. The location is %ProgramData%\Datadog .NET Tracer\logs\ on Windows and /var/log/datadog/dotnet/ on Linux
There are two kinds of logs. From Tracer 1.26.0 onward, the native part leaves a log named dotnet-tracer-native-(process name)-(process ID).log and the managed part one named dotnet-tracer-managed-(process name)-(date).log. Because the process name is included in the name, if there is no file for the target process, you can surmise that the Tracer has not been loaded yet. What matters last in an IIS rollout is planning. For the next piece of work, first decide which server's IIS can be stopped and when, and build a plan that, within that window of time, carries straight through the WAS restart, accessing the site, and the check with dd-dotnet check iis.