prometheus / prometheus/client_rust
Counter API is overly restrictive
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 606
- Forks
- 113
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 8
Description
Currently Counter's API is:
https://github.com/prometheus/client_rust/blob/master/src/metrics/counter.rs#L76-L83
/// Increase the [`Counter`] by 1, returning the previous value.
pub fn inc(&self) -> N {
self.value.inc()
}
/// Increase the [`Counter`] by `v`, returning the previous value.
pub fn inc_by(&self, v: N) -> N {
self.value.inc_by(v)
}
which requires inc and inc_by to return the previous value. This is rarely needed for metric collecting use-case, and it hinders the ability to use per-thread thread-local accumulator to prevent contention (like this) and increase performance.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing src/metrics/counter.rs at lines 76-83 and the linked hytra::TrAdder design. Determine the intended Counter increment API and how its return-value requirement affects thread-local accumulation and contention. Done should include an agreed API shape and coverage for the changed increment behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100