Resource Detection

Built-in resource detectors for distribution metadata, Kubernetes pod UID, and service name fallback from package.json.

The distribution adds resource attributes that describe the process, the host, the container and the Kubernetes pod the application runs in.

Detectors

Without a configuration file, the distribution uses these resource detectors:

DetectorAttributes
EnvironmentAttributes from OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES.
Processprocess.* attributes, such as process.pid, process.runtime.name and process.runtime.version.
Containercontainer.id.
Hosthost.* attributes, such as host.name and host.arch.
Kubernetes pod UIDk8s.pod.uid, when running in Kubernetes.
Service name fallbackservice.name and service.version from package.json, if no service name is set.

In addition, the distribution always sets telemetry.distro.name to dash0-nodejs and telemetry.distro.version to the version of the distribution.

If OTEL_NODE_RESOURCE_DETECTORS is set, the environment, process, container and host detectors are replaced by the detectors it names, as documented by auto-instrumentations-node . The Kubernetes pod UID and service name fallback detectors are always added.

Kubernetes pod UID

When the distribution detects that it runs in Kubernetes, by checking that /etc/hosts is managed by Kubernetes, it reads the pod UID from the cgroup information of the process (/proc/self/mountinfo for cgroup v1, /proc/self/cgroup for cgroup v2). It sets the k8s.pod.uid resource attribute to the result. Dash0 uses this attribute to associate telemetry with the Kubernetes pod.

Service name fallback

If no service name has been set, the distribution reads the main package.json of the application:

  • The service.name resource attribute is set to the value of the name attribute in package.json.
  • The service.version resource attribute is set to the value of the version attribute in package.json.

The fallback does not apply if OTEL_SERVICE_NAME is set, if OTEL_RESOURCE_ATTRIBUTES contains service.name, or if DASH0_AUTOMATIC_SERVICE_NAME=false is set. A process that then has no name reports the SDK's unknown_service name.

How the service name is chosen

Without a configuration file, the first of these that is set gives the service.name:

  1. OTEL_SERVICE_NAME.
  2. service.name in OTEL_RESOURCE_ATTRIBUTES.
  3. The service name fallback.

With a configuration file that reads OTEL_RESOURCE_ATTRIBUTES through attributes_list, the first two swap places. Attributes set in the file take precedence over every detector, including the service detector that reads OTEL_SERVICE_NAME.

Detectors in a configuration file

With a declarative configuration file, only the detectors named in the file run. The file can name the upstream host, process and service detectors, and the distribution's own:

DetectorAttributes
hosthost.* and os.* attributes.
processprocess.* attributes.
serviceservice.instance.id, and service.name from OTEL_SERVICE_NAME.
dash0_distributiontelemetry.distro.name and telemetry.distro.version.
dash0_kubernetesk8s.pod.uid, when running in Kubernetes.
dash0_service_nameservice.name, if no other service name is configured, ignoring the unknown_service default.

dash0_service_name uses OTEL_SERVICE_NAME if set, and otherwise derives service.name and service.version from the application's package.json, like the service name fallback does without a configuration file. Setting DASH0_AUTOMATIC_SERVICE_NAME=false turns off the package.json fallback. OTEL_RESOURCE_ATTRIBUTES is not consulted; reference it from the file via attributes_list instead.

Other detectors, such as container, aws or gcp, are not available in a configuration file.

resource:
  detection/development:
    detectors:
      - host: {}
      - process: {}
      - service: {}
      - dash0_distribution: {}
      - dash0_service_name: {}
      - dash0_kubernetes: {}
  attributes_list: ${OTEL_RESOURCE_ATTRIBUTES:-}

Attributes set in the file take precedence over those from these detectors.

A file that names all six detectors reports these attributes differently from the distribution without a configuration file:

AttributesWithout a configuration fileWith the six detectors
os.*noyes
service.instance.idnoyes
container.idyesno

Your own attributes

Add attributes with OTEL_RESOURCE_ATTRIBUTES, as comma-separated key=value pairs. A configuration file reads it only through attributes_list, as in the example above.

Last updated: