Resource Detection
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:
| Detector | Attributes |
|---|---|
| Environment | Attributes from OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES. |
| Process | process.* attributes, such as process.pid, process.runtime.name and process.runtime.version. |
| Container | container.id. |
| Host | host.* attributes, such as host.name and host.arch. |
| Kubernetes pod UID | k8s.pod.uid, when running in Kubernetes. |
| Service name fallback | service.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.nameresource attribute is set to the value of thenameattribute inpackage.json. - The
service.versionresource attribute is set to the value of theversionattribute inpackage.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:
OTEL_SERVICE_NAME.service.nameinOTEL_RESOURCE_ATTRIBUTES.- 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:
| Detector | Attributes |
|---|---|
host | host.* and os.* attributes. |
process | process.* attributes. |
service | service.instance.id, and service.name from OTEL_SERVICE_NAME. |
dash0_distribution | telemetry.distro.name and telemetry.distro.version. |
dash0_kubernetes | k8s.pod.uid, when running in Kubernetes. |
dash0_service_name | service.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:
| Attributes | Without a configuration file | With the six detectors |
|---|---|---|
os.* | no | yes |
service.instance.id | no | yes |
container.id | yes | no |
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: