-
Notifications
You must be signed in to change notification settings - Fork 39
feat: add {emitToString, emitToBuffer} options + dedup TYPE and HELP per metric name #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add {emitToString, emitToBuffer} options + dedup TYPE and HELP per metric name #135
Conversation
…per metric name Add {emitToString, emitToBuffer} thread-safe internal buffer management variants to emit metrics. Deduplicate TYPE and HELP lines per metric name by default on emit + enforce same HELP per metric name. Signed-off-by: Melissa Kilby <[email protected]>
… sharing Revert to stricter mutual exclusivity constraints for metric name sharing with respect to labeled and unlabeled cases while still allowing different label sets per metric name. While Prometheus wouldn't break with sharing a metric name for labeled and unlabeled variants, the client enforces that each unique metric name must either be labeled (allowing multiple label sets) or unlabeled in order to support correct Prometheus aggregations. Use MetricFamily instead of MetricGroup. Signed-off-by: Melissa Kilby <[email protected]>
72e503b
to
1184ea7
Compare
New emit variants should address thread-safety requirements #136. |
Fixes #137 |
Move constraint checks into MetricFamily and adopt an approach that favors immutability of MetricFamily members. Co-authored-by: Konrad `ktoso` Malawski <[email protected]> Signed-off-by: Melissa Kilby <[email protected]>
} | ||
} | ||
|
||
func add(metric: Metric, for labels: [(String, String)]) -> MetricFamily<Metric> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor and doesn’t have to be done, but fyi. In swift often the “add” would be mutating and the not mutating one would be “adding”. But this is fine, just internal api so no need to bikeshed too much
Reduce code duplication further by adding `removing`, `getMetric` and `forEachMetric` to `MetricFamily`. Rename `add` -> `adding` to indicate non mutating nature (Swift convention). Co-authored-by: Konrad `ktoso` Malawski <[email protected]> Signed-off-by: Melissa Kilby <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm!
Add {emitToString, emitToBuffer} thread-safe internal buffer management variants to emit metrics.
Deduplicate TYPE and HELP lines per metric name by default on emit.
Fixes #118 @ptoffy
CC @ktoso and @FranzBusch