Resource/Trace doesn't show up under correct service
Security Monitoring is now available Security Monitoring is now available

Resource/Trace doesn't show up under correct service

When using a custom instrumentation of your application, if you notice any resources/traces in the Datadog UI that aren’t coupled the service you expect, the most likely scenario is explained below.

A resource is connected to a service by more than the service Name - it is also done via the Name of the top-level span of the trace. This means that a service requires a top level name to be consistent across your resources.
See this in the following image in the address bar:

  1. The service name that is defined for all of these resources (The name selected from the services page in the UI).

  2. The top level name that was applied for each resource during custom instrumentation.

If any resource displays in the UI under another service, despite having the same service name, it is important to ensure that the top level name is the same as the other resources within the expected service.

For example, if you have a resource with a service named tornado-notification with a top level name of tornado.notify, any resource that had both this service Name and top level Name applied would display under this service. However, if you have a resource that has a service name of tornado-notification with a top level name of web_identification, this resource won’t be available under the existing tornado-notification | tornado.notify service in the UI.

These resources, with a top level name of web_identification still appear in the Datadog Application, and can be viewed under the traces section of the APM navigation menu.

An example of modifying the top level name for Python can be found below:

    def do_something(self):
        # do something

This function explicitly sets both the service name and Top Level Name, being tornado-notification and tornado.notify respectively.

Also note that the resource name is set manually, MainHandler.do_something.

By default the resource name would be set to this as it’s the name of the function and the class for which it lives under in Tornado.

More examples and documentation can be found on our language-specific instrumentation documentation pages:

OpenTracing Top Level Spans

To fix this when using OpenTracing, set the resource name to ensure that your resources are unique while sharing one consistent operation name for a service.

In Java, this can be done by setting DDTags.RESOURCE_NAME from import datadog.trace.api.DDTags.