-
Notifications
You must be signed in to change notification settings - Fork 1k
[Spring starter] Make sdk bean overridable and cache env calls #15132
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
base: main
Are you sure you want to change the base?
Conversation
...lemetry/instrumentation/spring/autoconfigure/internal/properties/SpringConfigProperties.java
Outdated
Show resolved
Hide resolved
...lemetry/instrumentation/spring/autoconfigure/internal/properties/SpringConfigProperties.java
Outdated
Show resolved
Hide resolved
| @Override | ||
| public String getString(String name) { | ||
| String normalizedName = ConfigUtil.normalizeEnvironmentVariableKey(name); | ||
| String value = environment.getProperty(normalizedName, String.class); |
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.
An alternative approach that could be considered would be to wrap the environment into a caching PropertyResolver. I presume that the sdk deliberately rereads these properties so they could be updated with opamp in the future. Idk whether this is something we should be concerned with.
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 presume that the sdk deliberately rereads these properties
no, it was not a deliberate decision as far as I know.
When I worked on the project, I assumed that properties would only be read at startup time.
I think it's hard to anticipate how OpAMP will be integrated, but we may simply flush the cache (from the caching PropertyResolver.
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.
implemented a caching property resolver, and included a way to flush the cache
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.
great!
| } | ||
|
|
||
| @Bean | ||
| @ConditionalOnMissingBean |
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.
why?
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 added this to allow people to customize the behavior, if they wanted
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.
we already have
Line 83 in 2e450ea
| @ConditionalOnMissingBean(OpenTelemetry.class) |
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.
in the original issue #15009 they asked to be able to override this:
The auto-configuration should allow overriding or replacing SpringConfigProperties gracefully, for example by supporting @ConditionalOnMissingBean, so users can provide a cached or customized implementation without having to fork the library.
But since we addressed the performance issue, perhaps it's less necessary?
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, I think so
adding @ConditionalOnMissingBean increases the API surface area in ways that also increase complexity
Fixes #15009
Add ability for users to customize AutoConfiguredOpenTelemetrySdk, and add cache for environment config lookups.