-
Notifications
You must be signed in to change notification settings - Fork 452
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
[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. |
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 |
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)
@@ -56,9 +51,9 @@ pub trait MeterProvider { | |||
/// 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 GlobalMeterProvider
ObjectSafeMeterProvider
and GlobalMeterProvider
ObjectSafeMeterProvider
and GlobalMeterProvider
ObjectSafeMeterProvider
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 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)
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
MeterProvider
trait in future.
@TommyCpp merging now to unblock progress on api. We can follow up if there are additional feedback to be addressed. |
Context
MeterProvider
trait is not object safe because the methods ofMeterProvider
trait have generic parametersGlobalMeterProvider
and a traitObjectSafeMeterProvider
to work around thisMeter
name, version and schema_url should be static string slices. Doing so would also makeMeterProvider
object safe.Changes
MeterProvider
trait object safe by updating its method signatures to accept&'static str
types instead of the genericimpl Into<Cow<'static, str>>
GlobalMeterProvider
andObjectSafeMeterProvider
trait as they are no longer necessaryMerge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes