Skip to content

feat: Add Summary metric type #254

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

tisonkun
Copy link

This closes #40.

This follows up #67.

With ...

@tisonkun
Copy link
Author

cc @mxinden

Comment on lines +9 to +10
#[cfg(feature = "summary")]
pub mod summary;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we add this line...

Suggested change
#[cfg(feature = "summary")]
pub mod summary;
#[cfg(feature = "summary")]
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
pub mod summary;

we'll also make sure that this shows up in the documentation generated on docs.rs, see: https://doc.rust-lang.org/rustdoc/unstable-features.html#doccfg-recording-what-platforms-or-features-are-required-for-code-to-be-present

n.b. we'd need to also add this above in lib.rs, if it's not already present:

#![cfg_attr(docsrs, feature(doc_cfg))]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use this trick for my crates and I'm glad to include this.

However, it seems a separated topic to this PR so I'd like to listen to maintainer's idea whether we should include it in this PR or add in a follow-up. Both works for me but different maintainers would have different preference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine either way. Preference for a separate pull request.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Then let's leave this PR as is.

@codefever
Copy link

Hi, is this feature still in progress?

@tisonkun
Copy link
Author

@codefever I'd like to. But without a maintainer involved I won't allocate more time since all may be in vain.

@tisonkun
Copy link
Author

Somehow I've switched to opentelemetry's metrics API, like apache/opendal#5524

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for picking up this effort.

Overall looks good to me. A couple of questions.

I am sorry this is not moving faster. Maintaining prometheus-client is a side project of mine and given that I don't have a usecase for Summary myself, I am not prioritizing it.

@@ -22,8 +23,12 @@ dtoa = "1.0"
itoa = "1.0"
parking_lot = "0.12"
prometheus-client-derive-encode = { version = "0.5.0", path = "derive-encode" }

# Optional dependencies
fastant = { version = "0.1", optional = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with fastant. Can you give a short summary why you chose it? I understand that instant is deprecated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you chose it

We (the fastlabs members) maintain it and use it in large scale production env via fastrace. So far, so good.

It provides a monotonically non-decreasing clock, which is what is required here.

/// Observe the given value.
pub fn observe(&self, v: f64) {
let mut inner = self.inner.write();
self.rotate_buckets(&mut inner);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for passing inner here.

@tisonkun
Copy link
Author

Questions answered. Please let me know if there is any pending items.

@tisonkun tisonkun requested a review from mxinden March 27, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Summary metric
4 participants