fix(encoding): do not encode descriptor of empty family#279
Merged
Conversation
d17742b to
2f0b0ab
Compare
mxinden
reviewed
Aug 14, 2025
Member
mxinden
left a comment
There was a problem hiding this comment.
Thanks for the patch.
Needs a test and a changelog entry.
In addition, can you point to the corresponding code in the Golang client?
TymanWasTaken
added a commit
to Polyfrost/backend
that referenced
this pull request
Aug 16, 2025
2f0b0ab to
1d7f079
Compare
Contributor
Author
|
Seems like the go code doing this is here: https://github.com/prometheus/client_golang/blob/84a4734fe73aecc9ec36e1fbcb09c9a2d679f392/prometheus/internal/metric.go#L82-L101 |
27e9c41 to
74c450a
Compare
mxinden
reviewed
Sep 2, 2025
Member
|
I don't have permissions to apply the above suggestions. Mind granting me those permissions, or applying them yourself? |
74c450a to
2109c5d
Compare
Signed-off-by: Jean-Baptiste Skutnik <jskutnik@ddn.com>
Signed-off-by: Jean-Baptiste Skutnik <jskutnik@ddn.com>
2109c5d to
82e1d7c
Compare
Contributor
Author
|
I rebased and applied the changes in the mix. |
eleboucher
pushed a commit
to eleboucher/towonel
that referenced
this pull request
Apr 18, 2026
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [prometheus-client](https://github.com/prometheus/client_rust) | workspace.dependencies | minor | `0.22` → `0.24` | --- ### Release Notes <details> <summary>prometheus/client_rust (prometheus-client)</summary> ### [`v0.24.1`](https://github.com/prometheus/client_rust/blob/HEAD/CHANGELOG.md#0241) [Compare Source](prometheus/client_rust@v0.24.0...v0.24.1) ##### Added - `EncodeGaugeValue` is implemented for `usize` and `isize`, and `EncodeCounterValue` is implemented for `usize`. See [PR 282]. ##### Fixed - `EncodeGaugeValue`, `EncodeCounterValue` and `EncodeExemplarValue` now use fewer `as` casts in their implementation. This caught an issue where `EncodeGaugeValue` would not error when encoding some `u64`s that don't fit in a `i64`. See [PR 281]. - Filter out empty metric families, to match the go client. See [PR 279]. - `Histogram` now exposes `count()` and `sum()` methods when the `test-util` feature is enabled. See [PR 242]. - `Family` now exposes a `contains()` method when the `test-util` feature is enabled. See [PR 245]. - `Family` now exposes `len()` and `is_empty()` methods when the `test-util` feature is enabled. See [PR 246]. [PR 279]: prometheus/client_rust#279 [PR 281]: prometheus/client_rust#281 [PR 242]: prometheus/client_rust#242 [PR 245]: prometheus/client_rust#245 [PR 246]: prometheus/client_rust#246 [PR 281]: prometheus/client_rust#281 [PR 282]: prometheus/client_rust#282 ### [`v0.24.0`](https://github.com/prometheus/client_rust/blob/HEAD/CHANGELOG.md#0240) [Compare Source](prometheus/client_rust@v0.23.1...v0.24.0) ##### Added - `EncodeLabelSet` is now implemented for tuples `(A: EncodeLabelSet, B: EncodeLabelSet)`. See [PR 257]. - `Family::get_or_create_owned` can access a metric in a labeled family. This method avoids the risk of runtime deadlocks at the expense of creating an owned type. See [PR 244]. - `impl<T: Collector> Collector for std::sync::Arc<T>`. See [PR 273]. [PR 244]: prometheus/client_rust#244 [PR 257]: prometheus/client_rust#257 [PR 273]: prometheus/client_rust#273 ##### Changed - `EncodeLabelSet::encode()` now accepts a mutable reference to its encoder parameter. - Exemplar timestamps can now be passed, which are required for `convert_classic_histograms_to_nhcb: true` in Prometheus scraping. See [PR 276]. [PR 276]: prometheus/client_rust#276 ### [`v0.23.1`](https://github.com/prometheus/client_rust/blob/HEAD/CHANGELOG.md#0231) [Compare Source](prometheus/client_rust@v0.23.0...v0.23.1) ##### Changed - `Histogram::new` now accepts an `IntoIterator` argument, rather than an `Iterator`. See [PR 243]. [PR 243]: prometheus/client_rust#243 ### [`v0.23.0`](https://github.com/prometheus/client_rust/blob/HEAD/CHANGELOG.md#0230) [Compare Source](prometheus/client_rust@v0.22.3...v0.23.0) ##### Changed - `ConstCounter::new` now requires specifying the type of literal arguments, like this: `ConstCounter::new(42u64);`. See [PR 173]. - Update `prost` dependencies to `v0.12`. See [PR 198]. - Implement `Atomic<u64>` for `AtomicU64` for gauges. See [PR 226]. - Implement `EnableLabelValue` for `bool`. See [PR 237] [PR 173]: prometheus/client_rust#173 [PR 198]: prometheus/client_rust#198 [PR 226]: prometheus/client_rust#226 [PR 237]: prometheus/client_rust#237 ##### Added - Support `i32`/`f32` for `Gauge` and `u32`/`f32` for `Counter`/`CounterWithExemplar`. See [PR 173] and [PR 216]. - Supoort `Arc<String>` for `EncodeLabelValue`. See [PR 217]. - Add `histogram::exponential_buckets_range`. See [PR 233]. - Added `get` method to `Family`. See [PR 234]. [PR 173]: prometheus/client_rust#173 [PR 216]: prometheus/client_rust#216 [PR 217]: prometheus/client_rust#217 [PR 233]: prometheus/client_rust#233 [PR 234]: prometheus/client_rust#234 ##### Fixed - Don't prepend `,` when encoding empty family label set. See [PR 175]. [PR 175]: prometheus/client_rust#175 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJ0eXBlL21pbm9yIl19--> Reviewed-on: https://git.erwanleboucher.dev/eleboucher/towonel/pulls/7
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.
Fixes #271. The implementation should be extensible and a user choice when implementing
is_emptyon theEncodeMetrictrait. This disables metric descriptor generation on families. The original issue does not make clear if this is an implementation choice or a bug, I can feature-gate the change if this is a choice.