# Using SL Multiprofiler with DataDog on IIS (Windows)

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

Install the **Datadog Tracer for DotNet** into a different folder than `C:\Program Files\`, for example, `“C:\DataDog-Tracer”`.

Open your Windows **System Properties** dialog, and in the **Environment Variables** section, **remove the following ones** if they have been set:

{% code overflow="wrap" lineNumbers="true" %}

```powershell
COR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8}
COR_PROFILER_PATH_64=C:\path\to\Datadog.Trace.ClrProfiler.Native.dll
COR_PROFILER_PATH_32=C:\path\to\Datadog.Trace.ClrProfiler.Native.dll
CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8}
CORECLR_PROFILER_PATH_64=C:\path\to\Datadog.Trace.ClrProfiler.Native.dll
CORECLR_PROFILER_PATH_32=C:\path\to\Datadog.Trace.ClrProfiler.Native.dll
```

{% endcode %}

Install the **Sealights .Net Agent**, for example, in `C:\Sealights\dotnet-agent\` directory and place there your agent token as a `sltoken.txt` file (Optional).

{% hint style="warning" %}
Installing the **Datadog tracer for .NET** in a folder other than `C:\Program Files` is **mandatory** to avoid permission issues when IIS applications attempt to access that directory. This requirement ensures that Sealights’ Multiprofiler solution can properly load the Datadog profiler without restrictions. Please note that the Datadog agent itself may remain in its default location, as only the tracer must reside in a path freely accessible by IIS processes.
{% endhint %}

## Setup <a href="#setup" id="setup"></a>

1. Set the environment variables for the IIS Services (WAS and W3SVC) to specify the parameters needed by the Sealights and DataDog agents.

{% hint style="info" %}
In the given sample configuration example below:

* Change the `“SL_”` settings depending on your Sealights configuration use case
* The **Datadog Tracer** is installed in the folder `“C:\DataDog-Tracer”` instead of `“C:\Program Files”` (as explained in the prerequisites)
  {% endhint %}

{% code overflow="wrap" lineNumbers="true" %}

```
CORECLR_ENABLE_PROFILING=1
CORECLR_PROFILER={9AAFB4C3-2E86-4C10-96D5-07E28F98554D}
CORECLR_PROFILER_PATH_64=C:\sealights\dotnet-agent\SL.DotNet.MultiProfilerLib.Windows_x64.dll
SL_EXT_PROFILER_1_NAME=Sealights
SL_EXT_PROFILER_1_PATH=C:\sealights\dotnet-agent\SL.DotNet.ProfilerLib.Windows_x64.dll
SL_EXT_PROFILER_1_GUID={01CA2C22-DC03-4FF5-8350-59E32A3536BA}
SL_EXT_PROFILER_2_NAME=DataDog
SL_EXT_PROFILER_2_PATH=C:\DataDog-Tracer\win-x64\Datadog.Trace.ClrProfiler.Native.dll
SL_EXT_PROFILER_2_GUID={846F5F1C-F9AE-4B07-969E-05C26BC060D8}
DD_PROFILING_ENABLED=1
SL_MP_LOGLEVEL=6
SL_MP_LogDir=C:\sealights\logs\multiprofiler
SL_AGENT_PORT=31031
SL_LOGGING_ENABLED=true
SL_Logging_toFile=true
SL_LOGGING_FileName=C:\sealights\logs\collector\listener_pic_iis
SL_EXE_PATH=C:\sealights\dotnet-agent\SL.DotNet.exe
SL_LogDir=C:\sealights\logs\
SL_LOGLEVEL=6
SL_SESSION_TOKENFILE=C:\sealights\dotnet-agent\sltoken.txt
SL_PROFILER_INITIALIZECOLLECTOR=1
SL_PROFILER_BLOCKING_CONNECTION_STARTUP=ASYNC
SL_SESSION_BUILDSESSIONIDFILE=C:\sealights\buildSessionId.txt
SL_LABID=integ_main_TestAppWeatherApi
```

{% endcode %}

If you're configuring the CD Agent, you'll need to add the following variables

{% code overflow="wrap" lineNumbers="true" %}

```
SL_PROFILER_INITIALIZECOLLECTOR_MODE=cdAgent
SL_FEATURES_IDENTIFYMETHODSBYFQN=true
SL_GENERAL_APPNAME=TestAppWeatherApi
SL_GENERAL_BRANCHNAME=main
SL_GENERAL_BUILDNAME=PICCDAGENT-IIS-5
SL_SCAN_BINDIR=C:\inetpub\wwwroot\WeatherForecast\
SL_SCAN_INCLUDENAMESPACES_0=WeatherForecast.*
SL_SCAN_INCLUDEASSEMBLIES=*WeatherForecast
```

{% endcode %}

2. Open the registry keys and update both:\
   **Computer\HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Services\WAS**\
   **Computer\HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC**\
   by adding a new Multi-String value called **Environment** with the values defined above as their data

   <figure><img src="https://4057366433-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAjqTCMRYvHhDgsdPLUnc%2Fuploads%2FLDg7gAaEJzSbGUbhTNxL%2Fimage.png?alt=media&#x26;token=a54fbd10-7501-4e2d-a93d-6b2f3da26bf5" alt=""><figcaption></figcaption></figure>
3. **Completely stop and start IIS** by running the following commands as an administrator:

{% code overflow="wrap" lineNumbers="true" %}

```
net stop /y was 
net start w3svc
```

{% endcode %}

{% hint style="success" %}
&#x20;Upon successful completion of this step, you should see the following new entries in *Cockpit > Live Agent Monitor* for the **Sealights Profiler**:

* `CollectorServiceSession` for `dotnet` technology
* `Profiler`, displaying the version details of your application (with the connected Application Pool shown as a tag in the dedicated column)

The **Multiprofiler** will **not** appear in the *Cockpit Live Agent Monitor* because it is a local, offline tool, separate from the agent. The only way to confirm that it is working properly is to check its traces or logs, which you enable using the `SL_MP_LogDir` and `SL_MP_LOGLEVEL` environment variables.

For **DataDog**, you can follow your standard validation process. Typically, this involves reviewing the APM-dedicated tab in the DataDog Dashboard and ensuring no errors appear in the local DataDog profiler logs.
{% endhint %}
