-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Description
The OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES environment variables are a fundamental mechanic of configuring applications that generate OpenTelemetry data [^1].
The OpenTelemetryAutoConfiguration however, does not honor these env vars. Instead, it sets the service.name attribute to be the Spring Application name (which, by the way, is a pretty solid default), and additionally sets the non-standard service.group attribute (which does not exist in the OpenTelemetry semantic conventions for the service.* namespace [^2]) using the application group (if anything, the right attribute to set is service.namespace).
The behavior of OpenTelemetryAutoConfiguration should be changed as follows:
- The resource attributes coming in through the
management.opentelemetryshould be right-merged with (i.e., should override in case of attribute key conflict) the default resource. (this is already current behavior) - Right-merge the
OTEL_RESOURCE_ATTRIBUTES - Right-merge the
service.nameattribute ifOTEL_SERVICE_NAMEis set - If no
service.nameandservice.namespaceare set, right-merge the current Spring Boot-specific attributes.
For explanatory purposes, I prepared this branch: https://github.com/mmanciop/spring-boot/tree/opentelemetry-resource-env-vars
I am happy to finalize it (mostly: write the missing tests) if there is interest.
Note: I initially raised the issue on Micrometer Tracing (Issue #931).
[^1] https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration
[^2] https://opentelemetry.io/docs/specs/semconv/resource/#service