-
Notifications
You must be signed in to change notification settings - Fork 598
[Metrics API] [Breaking] Enforce meter name, version schema_url to be static string slices #2112
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
[Metrics API] [Breaking] Enforce meter name, version schema_url to be static string slices #2112
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2112 +/- ##
=======================================
- Coverage 78.3% 78.3% -0.1%
=======================================
Files 121 121
Lines 20815 20767 -48
=======================================
- Hits 16309 16269 -40
+ Misses 4506 4498 -8 ☔ View full report in Codecov by Sentry. |
TommyCpp
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.
If the concern here is object safety. I wonder if we can ask the implementation of MeterProvider to be Sized. Something like this https://rust-lang.github.io/api-guidelines/flexibility.html#traits-are-object-safe-if-they-may-be-useful-as-a-trait-object-c-object
I don't think it's a huge overhead. We basically only repeating the |
@TommyCpp The concern here is the extra bit of code ( The |
Apart from reducing the maintenance overhead, removing the public API also allows us to change things in the global metrics setup more freely if required in future. We won't be tying the setup process to any type other than There is no regression on readability/ergonomics, if the user is using |
Generally I'd agree. But in this case |
True. I am thinking about the regression on readability/ergonomics for users that don't use |
cijothomas
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.
This is good cleanup, but lets do it by making 'static str for MeterNames, as discussed here : #2112 (comment)
| /// default name will be used instead. | ||
| fn versioned_meter( | ||
| &self, | ||
| name: impl Into<Cow<'static, str>>, |
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.
@stormshield-fabs FYI. #1527 is still to be added for Metrics, which will remove versioned_meter in favor of builder pattern.
ObjectSafeMeterProvider and GlobalMeterProviderObjectSafeMeterProvider and GlobalMeterProvider
ObjectSafeMeterProvider and GlobalMeterProviderObjectSafeMeterProvider and GlobalMeterProvider by enforcing meter name,version,schema_url to be static string slices
ObjectSafeMeterProvider and GlobalMeterProvider by enforcing meter name,version,schema_url to be static string slices
cijothomas
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.
LGTM.
Please follow up with a breaking change entry to changelog for this (and previous 2 PRs that changed public api)
lalitb
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.
LGTM. Based on the following assumptions:
- Meter names are generally recommended to be static strings defined at compile time.
- There will be no need to make object unsafe addition to
MeterProvidertrait in future.
|
@TommyCpp merging now to unblock progress on api. We can follow up if there are additional feedback to be addressed. |
Context
MeterProvidertrait is not object safe because the methods ofMeterProvidertrait have generic parametersGlobalMeterProviderand a traitObjectSafeMeterProviderto work around thisMetername, version and schema_url should be static string slices. Doing so would also makeMeterProviderobject safe.Changes
MeterProvidertrait object safe by updating its method signatures to accept&'static strtypes instead of the genericimpl Into<Cow<'static, str>>GlobalMeterProviderandObjectSafeMeterProvidertrait as they are no longer necessaryMerge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changes