-
Notifications
You must be signed in to change notification settings - Fork 925
add "get" method to DeclarativeConfigProperties #7923
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
add "get" method to DeclarativeConfigProperties #7923
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7923 +/- ##
=========================================
Coverage 90.12% 90.13%
- Complexity 7318 7320 +2
=========================================
Files 824 824
Lines 22027 22028 +1
Branches 2177 2177
=========================================
+ Hits 19852 19854 +2
Misses 1498 1498
+ Partials 677 676 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
...cubator/src/main/java/io/opentelemetry/api/incubator/config/DeclarativeConfigProperties.java
Outdated
Show resolved
Hide resolved
…fig/DeclarativeConfigProperties.java Co-authored-by: Trask Stalnaker <[email protected]>
| * | ||
| * @return a map-valued configuration property, or an empty {@link DeclarativeConfigProperties} | ||
| * instance if {@code name} has not been configured | ||
| * @throws DeclarativeConfigException if the property is not a mapping |
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.
wdyt of not throwing exception for this (and other) methods which have default values?
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.
If we took this approach I think we'd want to go further and get rid of the the throws altogether. It would be strange if calling the non-default overload threw (rather than just returning null) while the default did not.
Going in this direction means we remove the ability to detect / handle schema type mismatches. It seems like a version of the "fail fast" vs. "handle gracefully and trudge on".
But hold on... the default YamlDeclarativeConfigProperties implementation does warn you if there is a type mismatch, but never throws! So all of these warnings are fake!
I do wonder if we should provide abilities to detect schema type mismatches and fail fast. API could look like:
boolean isStringOrNull(String name);
boolean isBooleanOrNull(String name);
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.
Discussed in the 12/18 java SIG and decided that:
- The
opentelemetry-java-instrumentationhas a preference for failing graceful (at least for now - we discussed both options in detail) - We should work to create actionable warning logs if the a config property type mismatch occurs.
- Current error messages only use the local context of the node. I.e.
Ignoring value for key [foo] because it is String instead of Integer: value - Good error messages would include the full path
Ignoring value for property [full.path.to.foo] because it is String instead of Integer: value
- Current error messages only use the local context of the node. I.e.
- It would be good to still allow for instrumentation libraries to fail fast. If the API defaults to leniency, then we'd need to provide additional APIs for facilitate this. Can add these when needed.
The work to strip out the @throws DeclarativeConfigException to reflect current behavior, and to improve error log messages can be done in separate PRs.
...cubator/src/main/java/io/opentelemetry/api/incubator/config/DeclarativeConfigProperties.java
Outdated
Show resolved
Hide resolved
…fig/DeclarativeConfigProperties.java Co-authored-by: Jack Berg <[email protected]>
jack-berg
left a comment
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'm not completely convinced that the method name get implies that I'm asking for a structured node back. Can't think of any better names that keep good UX, and the javadoc provides details, so let's just go ahead with this.
Addresses open-telemetry/opentelemetry-java-instrumentation#15641 (comment)