-
Notifications
You must be signed in to change notification settings - Fork 431
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] Update asynchronous instruments to not allow calling observe
outside of a callback
#2210
[Metrics API] Update asynchronous instruments to not allow calling observe
outside of a callback
#2210
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2210 +/- ##
=======================================
+ Coverage 79.1% 79.2% +0.1%
=======================================
Files 122 122
Lines 21042 21009 -33
=======================================
- Hits 16645 16644 -1
+ Misses 4397 4365 -32 ☔ 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.
Lets mention in changelog as this is breaking (though unlikely to affect anyone in practice)
@@ -33,7 +33,9 @@ impl<T> Gauge<T> { | |||
/// An async instrument that records independent readings. | |||
#[derive(Clone)] | |||
#[non_exhaustive] | |||
pub struct ObservableGauge<T>(Arc<dyn AsyncInstrument<T>>); | |||
pub struct ObservableGauge<T> { | |||
_marker: std::marker::PhantomData<T>, |
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.
nit: Declare the full type name of PhantomData
in use
?
observe
outside of a callbackobserve
outside of a callback
All the asynchronous instruments implement the trait
AsyncInstrument
which allows users to callobserve
method outside of the callbackChanges
AsyncInstrument
for each of the asynchronous instruments to not allow callingobserve
outside of a callback (as a side benefit, we also reduce the public API surface)AsyncInstrument
from each of asynchronous instruments as it was only used for implementation of itselfMerge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes