Open source

Recommended OpenTelemetry Resource Attributes

OpenTelemetry resource attributes are added to log, span, and metrics emitted by your application.

These service resource attributes allow you to filter your metrics and traces effectively:

service.namespaceAn optional namespace for
service.nameThe application name
deployment.environmentName of the deployment environment (staging or production)
service.instance.idThe unique instance, e.g. the pod name
service.versionThe application version, to see if a new version has introduced a bug

OpenTelemetry logs and metrics are stored in Loki and Prometheus respectively. Both Loki and Prometheus use job and instance labels according the OpenTelemetry compatibility specification with Prometheus and OpenMetrics:

LabelFilled with attribute (if it is found)
job${service.namespace}/${} (if service.namespace is defined) or service.namespace

Java Resource Providers

When using the Java Agent or Grafana OpenTelemetry Starter1, a set of global attributes, also known as resource attributes, is added to each span, metric, and log entry. The attributes are managed via Resource Providers which are detailed here. You can enable/disable select providers using the following properties or environment variable.

System Property /
Environment Variable
Description /
Enables one or more ResourceProvider types. If unset, all resource providers are enabled and all associated attributes are sent. /
Disables one or more ResourceProvider types.

As an example, if you don’t want to expose the name of the operating system through the resource, you can pass the following system property on the command line to disable the OsResourceProvider:

java -jar app.jar

Or if you only want to see process resources such as PID, you could export the following environment variable to enable only the ProcessResourceProvdier:

export OTEL_JAVA_ENABLED_RESOURCE_PROVIDERS=io.opentelemetry.instrumentation.resources.ProcessResourceProvider

You can set multiple resource providers by separating them with a comma (,).

  1. To use the disable/enable properties with grafana-opentelemetry-starter:1.0.0 you will need to include io.opentelemetry.instrumentation:opentelemetry-resources:<otelVersion>-alpha as a runtime dependency. With later versions, you can simply set/export the property/variable. ↩︎