Skip to content
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

feat(metrics/family): add get method to Family #234

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

ethercflow
Copy link
Contributor

@ethercflow ethercflow commented Oct 28, 2024

Address comments in #230 (comment)

@ethercflow
Copy link
Contributor Author

@mxinden PTAL, thanks!

@cratelyn
Copy link
Contributor

seconding this addition, i would also suppport this change, and would like have the ability to avoid creating new metrics in a family when looking up the series for a particular label set. i'll cross-reference #244, which also introduces a new accessor to Family<S, M, C>.

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 the thorough patch.

What do you think of replacing the code below in Family::get_or_create with a call to Family::get?

        if let Ok(metric) =
            RwLockReadGuard::try_map(self.metrics.read(), |metrics| metrics.get(label_set))
        {
            return metric;
        }

Also, please add a changelog entry.

src/metrics/family.rs Outdated Show resolved Hide resolved
@ethercflow
Copy link
Contributor Author

@mxinden Addressed, PTAL, thanks!

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!

@mxinden mxinden merged commit 93c63db into prometheus:master Dec 3, 2024
10 checks passed
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.

3 participants