Skip to content

Commit

Permalink
metrics: assign histogram metric type on histogram construction
Browse files Browse the repository at this point in the history
This commit assigns prometheusgo.MetricType_HISTOGRAM to the
Metadata.MetricType on histogram construction.

Before this change, GetMetadata() was returning the
Metadata.MetricType zero value (prometheusgo.MetricType_COUNTER)
for all histograms that did not explicitly specify the
prometheusgo.MetricType_HISTOGRAM for Metadata.MetricType in
their Metadata definitions. This prevented checks on histogram
Metadata.MetricType from properly evaluating the metrics as
histograms.

Fixes cockroachdb#106448.
Fixes cockroachdb#107701.

Releaes note: None
  • Loading branch information
ericharmeling committed Aug 21, 2023
1 parent 9ad8453 commit d0f11b7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/util/metric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ type HistogramOptions struct {
}

func NewHistogram(opt HistogramOptions) IHistogram {
opt.Metadata.MetricType = prometheusgo.MetricType_HISTOGRAM
if hdrEnabled && opt.Mode != HistogramModePrometheus {
if opt.Mode == HistogramModePreferHdrLatency {
return NewHdrLatency(opt.Metadata, opt.Duration)
Expand Down Expand Up @@ -492,6 +493,7 @@ func NewManualWindowHistogram(
panic(err.Error())
}

meta.MetricType = prometheusgo.MetricType_HISTOGRAM
h := &ManualWindowHistogram{
Metadata: meta,
}
Expand Down

0 comments on commit d0f11b7

Please sign in to comment.