-
Notifications
You must be signed in to change notification settings - Fork 944
make spring boot honor the standard environment variables for maps #11000
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The map properties defined with an environment variable seems to take precedence over the map properties defined from a .properties
/ .yml
file? It may be worth to document this in the next release.
...io/opentelemetry/instrumentation/spring/autoconfigure/properties/SpringConfigProperties.java
Outdated
Show resolved
Hide resolved
...io/opentelemetry/instrumentation/spring/autoconfigure/properties/SpringConfigProperties.java
Outdated
Show resolved
Hide resolved
Spring also gives precedence to environment variables, so I think spring users will expect that. |
The possibility of overriding some map values with an environment variable could be documented. |
I'd argue this is standard spring behavior, but I'm happy to point that out in the docs. I'll link the PR here once done. |
|
* If you specify the environment variable <code>OTEL_RESOURCE_ATTRIBUTES_POD_NAME</code>, then | ||
* Spring Boot will ignore <code>OTEL_RESOURCE_ATTRIBUTES</code>, which violates the principle of | ||
* least surprise. This method merges the two maps, giving precedence to <code> | ||
* OTEL_RESOURCE_ATTRIBUTES_POD_NAME</code>, which is more specific and which is also the value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the env var mapping makes me a little nervous since some otel resource attribute names include underscores
but I think we can argue that this is just a spring configuration feature(?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't follow - what are you nervous about? Maybe an example would help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some OTel resource attributes have underscores in them, and so it's not clear to me how these would work with env vars, e.g. does OTEL_RESOURCE_ATTRIBUTES_X_Y_Z
correspond to resource attribute x.y.z
, x.y_z
, x_y.z
, or x_y_z
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, now I get it!
Based on that, I'd say:
OTEL_RESOURCE_ATTRIBUTES_X_Y_Z
should only be used to update anx.y.z
orx_y_z
that you have defined in application.yaml- use
OTEL_RESOURCE_ATTRIBUTES
if you want to introduce new resource attributes
I think open-telemetry/opentelemetry.io#4241 is the right place to elaborate on this distinction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, OTEL_RESOURCE_ATTRIBUTES_X_Y_Z
results in x.y.z
- which is indeed a spring boot feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OTEL_RESOURCE_ATTRIBUTES_X_Y_Z
should only be used to update an x.y.z or x_y_z that you have defined in application.yaml
oh, so it will auto-match if you have something matching already defined in application.yaml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it will auto match.
8b1e53b
to
25c61f1
Compare
Fixes #10959