prometheus / prometheus/client_rust
feat: derive register logic on struct of metrics
Open
Nobody has claimed this yet.
enhancement
good first issue
help wanted
- Dominant language
- Rust
- Stars
- 606
- Forks
- 113
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 8
Description
One oftentimes has a struct of metrics like:
struct Metrics {
a: Counter,
b: Gauge,
}
Code to register the metrics in Metrics with a Registry could be generated via a derive macro on Metrics.
- The metric name would be taken from the field name.
- The metric help text would be taken from the Rust doc String.
- The metric unit could be provided via a macro attribute.
#[derive(Register)]
struct Metrics {
/// My Gauge tracking the number of xxx
a: Counter,
/// My Counter, tracking the event xxx
#[prometheus-unit(Seconds)]
b: Gauge,
}
Where the Register trait is something along the lines of:
trait Register {
fn create_and_register(registry: &mut Registry) -> Self;
}
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 with the proposed Register trait and the derive example in the issue. Determine how field names, Rust doc strings, and the prometheus-unit attribute should map to metric registration, then define what generated create_and_register behavior must produce for the Metrics example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100