-
Notifications
You must be signed in to change notification settings - Fork 6
Create functions to create u64 and f64 exponential histograms #94
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
Conversation
($method: ident, $ty:ty, $var_name:literal, $usage:literal) => { | ||
($method: ident, $ty:ty, $var_name:literal, $usage:literal, $show_header: ident) => { | ||
concat!( | ||
"Wrapper for [`Meter::", stringify!($method), "`] using Pydantic Logfire's global meter. | ||
metric_doc_header!($show_header, $method), | ||
" |
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.
It would be nice to have an alternative header for the exponential histograms, which explains what they are, given there isn't an upstream doc to link to.
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.
Makes sense. Will add it
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.
Added
src/metrics.rs
Outdated
let mut histograms = EXPONENTIAL_HISTOGRAMS | ||
.write() | ||
.unwrap_or_else(std::sync::PoisonError::into_inner); | ||
let name = name.into(); | ||
histograms.insert(name.clone(), scale); | ||
u64_histogram(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.
Should we potentially wrap the return value as a struct ExponentialHistogram
so that on drop it can remove the name from the global? Might be cleaner.
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 could also remove from the map after the histogram is passed to the view function. I'm not completely sure that removing from the map is safe since the spec doesn't say how many times the view function will be called for each metric.
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.
Agreed, I think if we clean up we should do it when the whole instrument is dropped.
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 Drop to clean up
src/metrics.rs
Outdated
.unwrap_or_else(std::sync::PoisonError::into_inner); | ||
let name = name.into(); | ||
histograms.insert(name.clone(), scale); | ||
f64_histogram(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.
How does the base2 aggregation affect the bucketing going on here? Should this use a different underlying instrument to avoid any bucketing here being a problem?
@PoorlyDefinedBehaviour let's get CI green then we can merge this. We'll test it in our codebase and see what the data looks like once it's exported, etc. Sound good? |
Sounds good, hadn't seen this comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Thanks, let's ship this and see how it looks👍
SdkMeterProvider
Aggregation::Base2ExponentialHistogram
The feature
spec_unstable_metrics_views
is required to use the view functionality.