0

I'm trying to monitor several applications within the same site in IIS. With just running the msi of the tracer dd-trace-dotnet, I started to see the events, but these are registered as [site name]/[application] e.g default_web_site/docs_webhook
I would love to be able to logs them under a custom service name for each application, but according to the documentation, this is only possible at the site level.
Manual instrumentation is described for windows services, setting the environment variable DD_SERVICE_NAME in the registry entry HKLM\System\CurrentControlSet\Services\{service name}\Environment is enough, but does not apply to IIS applications.

NOTE: Creating separate sites for each application is not an option right now.

Lucas
  • 17,277
  • 5
  • 45
  • 40
Yasel
  • 2,920
  • 4
  • 40
  • 48

2 Answers2

3

For each web application that you want to configure with a different Datadog APM service name, you need to set the environment variable DD_SERVICE_NAME. If they're all running under the same IIS process, that's not possible.

In IIS there's a feature named Application Pool, which can be used to isolate multiple web applications by running them under different processes.

The first thing you need to do is to create a separate application pool for each web application. Once you're done with that, you can set a different DD_SERVICE_NAME for each application pool. The command to set an environment variable scoped to a specific application pool is

appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='MyAppPool'].environmentVariables.[name='DD_SERVICE_NAME',value='my-service']" /commit:apphost

where MyAppPool is the name of the application pool, and my-service is the service name that you want to use for the Datadog APM.

After running the above command, you have to restart IIS for the changes to take effect:

net stop was /y

net start w3svc
JTRH
  • 46
  • 1
  • 2
3

Starting with version 1.0 of Datadog's .NET Tracer, you can set most settings in your application's app.config/web.config file. For example, to set DD_SERVICE_NAME:

<configuration>
  <appSettings>
    <add key="DD_SERVICE_NAME" value="my-service"/>
  </appSettings>
</configuration>

[Disclaimer: I am a Datadog employee]

Lucas
  • 17,277
  • 5
  • 45
  • 40
  • Great! Question, should I add the Datadog.Trace NuGet package to my project to make this work? – Yasel Apr 07 '19 at 11:21
  • 2
    .NET Framework on IIS does not need the NuGet package unless you need to access the Tracer via code for some reason (like creating spans manually or adding custom tags to a span). – Lucas Apr 08 '19 at 16:49
  • what has higher precedence, the environment variables or the settings of the application? – Yasel May 23 '19 at 19:12