-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenTelemetry: Support OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES env vars #43712
Comments
The linked document states:
We chose not to use the environment variables and instead use the configuration system from Spring Boot. What's the reason that you want to set |
Did we forget about |
Because it is the standard OpenTelemetry way of doing things that people know from all other supported runtimes and languages. It avoids surprises when looking at applications through the lenses of deployment descriptors (like Kubernetes resources) and would work consistently in polyglot systems. |
I think so, but it is IMO a happy coincidence: the |
True. That's because it uses |
I'll discuss this with the team. |
The
OTEL_SERVICE_NAME
andOTEL_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 theservice.name
attribute to be the Spring Application name (which, by the way, is a pretty solid default), and additionally sets the non-standardservice.group
attribute (which does not exist in the OpenTelemetry semantic conventions for theservice.*
namespace [^2]) using the application group (if anything, the right attribute to set isservice.namespace
).The behavior of
OpenTelemetryAutoConfiguration
should be changed as follows:management.opentelemetry
should be right-merged with (i.e., should override in case of attribute key conflict) the default resource. (this is already current behavior)OTEL_RESOURCE_ATTRIBUTES
service.name
attribute ifOTEL_SERVICE_NAME
is setservice.name
andservice.namespace
are 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
The text was updated successfully, but these errors were encountered: