feat(metrics/family): 🍭 len() returns the number of metrics#246
Merged
mxinden merged 1 commit intoprometheus:masterfrom Jan 29, 2026
Merged
feat(metrics/family): 🍭 len() returns the number of metrics#246mxinden merged 1 commit intoprometheus:masterfrom
len() returns the number of metrics#246mxinden merged 1 commit intoprometheus:masterfrom
Conversation
len() returns the number of metricslen() returns the number of metrics
Contributor
Author
|
my understanding is that this could be added behind the |
cratelyn
commented
Jan 22, 2026
cratelyn
commented
Jan 22, 2026
Member
|
@cratelyn can you resolve the merge conflict? A bit tricky via GitHub UI. |
this commit introduces a `len()` method to `Family<S, M, C>`, which returns the number of series within a metric family. see also prometheus#245, which allows callers to check if a family `contains()` a given label set. ```shell $ cargo clippy --all-features --all-targets --tests Compiling prometheus-client v0.23.0 (/path/to/prometheus-client) warning: struct `Family` has a public `len` method, but no `is_empty` method --> src/metrics/family.rs:309:5 | 309 | pub fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty = note: `#[warn(clippy::len_without_is_empty)]` on by default warning: `prometheus-client` (lib) generated 1 warning warning: `prometheus-client` (lib test) generated 1 warning (1 duplicate) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.63s ``` Signed-off-by: katelyn martin <git@katelyn.world>
cratelyn
commented
Jan 28, 2026
Contributor
Author
yes, of course! i've rebased this on |
mxinden
approved these changes
Jan 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this commit introduces a
len()method toFamily<S, M, C>, which returns the number of series within a metric family.see also #245, which allows callers to check if a family
contains()a given label set.