Resource Detection
Note: This page is auto-generated from the opentelemetry-java-distribution repository.
The distribution adds a few resource attributes of its own and keeps every detector the upstream agent ships, with the same defaults. This page describes configuration from environment variables. A host with a declarative configuration file is covered at the end.
Attributes the distribution adds
| Attribute | Value |
|---|---|
telemetry.distro.name | dash0-java |
telemetry.distro.version | the version of this distribution |
dash0.package.name | the Dash0 Linux package that installed the agent, such as dash0-java-autoinstrumentation |
dash0.package.version | the version of that package |
The two dash0.package.* attributes are present only when the agent was installed by a Dash0 Linux package.
The package writes them to dash0-resource-attributes.properties in the directory of the agent jar, and the agent reads every key in that file.
The extension jar does not read the file.
If you set the same name with OTEL_RESOURCE_ATTRIBUTES, your value wins.
Detectors that run by default
| Attributes | Source |
|---|---|
container.id | the container runtime, when the JVM runs in a container |
host.name, host.arch | the host |
os.type, os.description, os.version | the operating system |
process.pid, process.executable.path, process.command_args | the JVM process |
process.runtime.name, process.runtime.version, process.runtime.description | the JVM |
service.instance.id | a random ID per process |
service.name, service.version | see below |
process.command_args contains the full command line.
The agent masks the values of system properties with names like password, so -Dpassword=hunter2 is exported as -Dpassword=***.
How the service name is chosen
The first of these that gives a name wins:
OTEL_SERVICE_NAME, orservice.nameinOTEL_RESOURCE_ATTRIBUTES.- A Spring application name.
The agent looks for
--spring.application.name=on the command line, thespring.application.namesystem property andSPRING_APPLICATION_NAME. It then looks inapplication.propertiesandapplication.ymlin the working directory and on the class path, and inbootstrapfiles on the class path. Implementation-Titlein the manifest of the jar started withjava -jar.- The file name of that jar, without
.jar. - Otherwise,
unknown_service:java.
With a configuration file that reads OTEL_RESOURCE_ATTRIBUTES through attributes_list, a service.name in OTEL_RESOURCE_ATTRIBUTES wins over OTEL_SERVICE_NAME, because the agent applies attributes_list after every detector.
| How the JVM is started | service.name |
|---|---|
java -cp … with nothing else set | unknown_service:java |
java -jar my-payments-service.jar | my-payments-service |
the same, with Implementation-Title: payments in the manifest | payments |
the same, plus -Dspring.application.name=my-spring-app | my-spring-app |
any of these, plus OTEL_SERVICE_NAME=checkout | checkout |
The Spring sources are read even when the application does not use Spring.
A spring.application.name meant for a different program in the same working directory becomes your service name.
Tomcat started with catalina.sh, the start scripts Gradle and Maven generate, and container images that run java -cp all end up with unknown_service:java.
Set OTEL_SERVICE_NAME for those workloads.
service.version comes from build.version in a Spring Boot META-INF/build-info.properties, or else from Implementation-Version in the jar manifest.
Cloud detectors
The cloud detectors are off by default, as they are in the upstream agent. Turn on the group for the cloud a workload runs on:
| Variable | Detectors |
|---|---|
OTEL_RESOURCE_PROVIDERS_AWS_ENABLED=true | EC2, ECS, EKS, Elastic Beanstalk, Lambda |
OTEL_RESOURCE_PROVIDERS_AZURE_ENABLED=true | Azure VM, App Service, Functions |
OTEL_RESOURCE_PROVIDERS_GCP_ENABLED=true | Google Cloud, including GCE, GKE, Cloud Run, Cloud Functions and App Engine |
OTEL_RESOURCE_PROVIDERS_CLOUDFOUNDRY_ENABLED=true | Cloud Foundry |
The matching system property is -Dotel.resource.providers.aws.enabled=true, and so on for the others.
Enable only the group for the cloud you are on.
The EC2, Azure VM and Google Cloud detectors call a metadata endpoint while the JVM starts, and the application waits for them.
On a host where that traffic is silently dropped, we measured the aws group adding about 4 seconds to startup and the azure group about 5 seconds.
The Google Cloud detector sets no timeout, so it can wait indefinitely when metadata.google.internal resolves but does not answer.
The other detectors only read environment variables or local files.
Only one of the AWS, Azure and Google Cloud detectors applies per process.
The first one that finds its cloud sets the cloud.* attributes, and the others are skipped.
On Azure App Service and Azure Functions, the azure group sets service.name from WEBSITE_SITE_NAME.
That replaces a name the JVM would otherwise get from Spring, the manifest or the jar file.
OTEL_SERVICE_NAME still wins.
Turning on part of a group
To use the ECS, Beanstalk and Lambda detectors without the EC2 metadata call, turn the group on and disable the EC2 detector:
export OTEL_RESOURCE_PROVIDERS_AWS_ENABLED=true
export OTEL_JAVA_DISABLED_RESOURCE_PROVIDERS=io.opentelemetry.contrib.aws.resource.Ec2ResourceProviderIn a Kubernetes pod that is not on EKS, also add io.opentelemetry.contrib.aws.resource.EksResourceProvider to the list.
That detector calls the Kubernetes API server, with a 2 second timeout, in every pod that mounts a service account token.
For the azure group, the detector to disable is io.opentelemetry.contrib.azure.resource.AzureVmResourceProvider.
Do not use OTEL_JAVA_ENABLED_RESOURCE_PROVIDERS to turn on one detector.
It runs only the detectors it names and switches off all others, including the ones that read OTEL_SERVICE_NAME and set telemetry.distro.name.
host.id
host.id is off by default.
Turn it on with OTEL_RESOURCE_PROVIDERS_HOST_ID_ENABLED=true.
On Linux it is read from /etc/machine-id.
That suits a host where a Dash0 Linux package installed the agent.
Do not turn it on in containers.
Every container built from the same image reports the same host.id, and some images, such as eclipse-temurin:21, have an empty /etc/machine-id and report none.
On macOS and Windows the agent starts a subprocess to read the ID, which adds to startup time.
Kubernetes
The distribution has no Kubernetes detector.
In a pod instrumented by the Dash0 operator, the operator sets k8s.namespace.name, k8s.pod.name, k8s.pod.uid and k8s.container.name through OTEL_RESOURCE_ATTRIBUTES.
In a pod the operator does not instrument, set them yourself the same way, for example with the Kubernetes downward API.
Under a configuration file
When a declarative configuration file configures the SDK, none of the detectors above run and the OTEL_RESOURCE_PROVIDERS_* toggles have no effect.
These run instead:
- the detectors the file names under
resource.detection/development, from the table below host,processandservice, which the distribution adds when the file does not name them- the agent's own detector for
telemetry.distro.*, whose values the Dash0 ones replace
The attributes differ from the ones above in three ways:
- The
hostdetector addshost.id, and it cannot be turned off separately fromhost.name. - The
processdetector does not addprocess.command_args. container.idis added only when the file names thecontainerdetector.
| Detector | Attributes |
|---|---|
host | host.name, host.arch, host.id and the os.* attributes |
process | process.pid, process.executable.path and the process.runtime.* attributes |
service | service.instance.id, and service.name from OTEL_SERVICE_NAME |
jar | service.name from the name of the jar passed to java -jar |
manifest | service.name and service.version from the jar manifest |
spring | service.name and service.version from Spring Boot |
container | container.id |
A later detector in the list overwrites an earlier one.
List service after jar, manifest and spring, so that OTEL_SERVICE_NAME wins when it is set.
Without jar, manifest and spring, a JVM that sets no OTEL_SERVICE_NAME reports unknown_service:java.
The distribution has no detector with a dash0_ name.
A detector name the agent does not know stops it from starting.
OTEL_RESOURCE_ATTRIBUTES applies only when the file refers to it, as the file from the Dash0 Linux packages does.
Values from the package's dash0-resource-attributes.properties win over detected values in this mode.
host.id is the contents of /etc/machine-id.
To leave it out, add it to resource.detection/development.attributes.excluded.
OTEL_JAVA_ENABLED_RESOURCE_PROVIDERS and OTEL_JAVA_DISABLED_RESOURCE_PROVIDERS have no effect under a configuration file either.
Your own attributes
Add attributes with OTEL_RESOURCE_ATTRIBUTES, as comma-separated key=value pairs.
A configuration file reads it only through attributes_list:
resource:
attributes_list: ${OTEL_RESOURCE_ATTRIBUTES:-}To drop a detected attribute under a configuration file, add a glob pattern matching its name to resource.detection/development.attributes.excluded.
Last updated: