fix(metrics): use short-lived local registry#1575
Merged
aawsome merged 1 commit intorustic-rs:mainfrom Oct 8, 2025
Merged
Conversation
Previously, this was using the global registry (via register_gauge!), which doesn't support re-registering metrics in this way, so only the first call to `PrometheusExporter::push_metrics` would succeed, while any later calls would return a (nested) `prometheus::Error::AlreadyReg`.
Ekleog
approved these changes
Oct 7, 2025
Contributor
Ekleog
left a comment
There was a problem hiding this comment.
Thank you for the fix! And sorry about that, it's definitely my mistake 😅
Merged
github-merge-queue bot
pushed a commit
that referenced
this pull request
Nov 8, 2025
## 🤖 New release * `rustic-rs`: 0.10.0 -> 0.10.1 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [0.10.1](v0.10.0...v0.10.1) - 2025-11-08 ### Added - Add rewrite command ([#1583](#1583)) - *(interactive)* Add --interactive option to ls ([#1564](#1564)) - Add filter-last option ([#1574](#1574)) - Add environment variable substitution in config files ([#1577](#1577)) ### Fixed - Fix typos using the typos tool ([#1590](#1590)) - *(metrics)* use short-lived local registry ([#1575](#1575)) - fix clippy lints ([#1570](#1570)) - wrong env var for grouping option ([#1566](#1566)) ### Other - update dependencies ([#1594](#1594)) - (security) Update fuser ([#1569](#1569)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). --------- Co-authored-by: rustic-release-plz[bot] <182542030+rustic-release-plz[bot]@users.noreply.github.com> Co-authored-by: Alexander Weiss <alex@weissfam.de>
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.
Previously, this was using the global registry (via register_gauge!), which doesn't support re-registering metrics in this way, so only the first call to
PrometheusExporter::push_metricswould succeed, while any later calls would return a (nested)prometheus::Error::AlreadyReg.This resulted in only the metrics for the first snapshot being pushed, while the metrics for subsequent snapshots errored with a somewhat vague error (the interior messages are not shown):
This PR more closely matches the behavior of the OpenTelemetry backend, which similarly only pushes the immediately-passed (as an argument) metrics, rather than including other metrics previously registered globally, as was the behavior with
prometheus::gather.There are likely less allocation-happy ways to solve this, but at the push frequency of rustic it doesn't matter.
cc @Ekleog as the original author of this module