-
Notifications
You must be signed in to change notification settings - Fork 38
refactor[Histograms]: uniquely identify metric time series by name and label sets (2/2) #134
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
refactor[Histograms]: uniquely identify metric time series by name and label sets (2/2) #134
Conversation
…bel sets Previously, {Value,Duration}Histograms could only be identified by their name. This change allows multiple {Value,Duration}Histograms to share the same name, with each unique set of labels defining a distinct time series. However, the buckets are immutable for a MetricGroup once initialized with the first metric. Additionally, the internal data structure for a stored metric has been refactored, providing a more robust and programmatic representation. Signed-off-by: Melissa Kilby <[email protected]>
0dadeef
to
7808b75
Compare
let help: String | ||
} | ||
|
||
private enum BucketType: Sendable, Hashable { |
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.
Doesn't feel like a "type" it is the actual buckets - plural because of collection of bucket which is one value in here
private enum BucketType: Sendable, Hashable { | |
private enum HistogramBuckets: Sendable, Hashable { |
self.buckets = buckets | ||
} | ||
|
||
init(metricsByLabelSets: [LabelsKey: MetricWithHelp<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.
i don't think we need this init; it can be just the previous one with buckets = nil
Co-authored-by: Konrad `ktoso` Malawski <[email protected]> Signed-off-by: Melissa Kilby <[email protected]>
61dbf5b
to
697b697
Compare
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.
Looks good :)
histogram2.recordNanoseconds(150_000_000) // 150ms | ||
histogram1.recordNanoseconds(1_500_000_000) // 1500ms | ||
histogram0.recordNanoseconds(800_000_000) // 800ms | ||
histogram2.recordNanoseconds(100_000_000) // 100ms |
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.
This is easier to write as
histogram.record(.milliseconds(100))
refactor: uniquely identify {Value,Duration}Histograms by name and label sets
Previously, {Value,Duration}Histograms could only be identified by their name. This change allows multiple {Value,Duration}Histograms to share the same name, with each unique set of labels defining a distinct time series.
However, the buckets are immutable for a MetricGroup once initialized with the first metric.
Additionally, the internal data structure for a stored metric has been refactored, providing a more robust and programmatic representation.
CC @ktoso @FranzBusch
Follow for #131, fixes #125