Skip to content
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

fix: use float histogram for otel metrics #1303

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions metrics/otel_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type OTelMetrics struct {

counters map[string]metric.Int64Counter
gauges map[string]metric.Float64ObservableGauge
histograms map[string]metric.Int64Histogram
histograms map[string]metric.Float64Histogram
updowns map[string]metric.Int64UpDownCounter

// values keeps a map of all the non-histogram metrics and their current value
Expand All @@ -52,7 +52,7 @@ func (o *OTelMetrics) Start() error {

o.counters = make(map[string]metric.Int64Counter)
o.gauges = make(map[string]metric.Float64ObservableGauge)
o.histograms = make(map[string]metric.Int64Histogram)
o.histograms = make(map[string]metric.Float64Histogram)
o.updowns = make(map[string]metric.Int64UpDownCounter)

o.values = make(map[string]float64)
Expand Down Expand Up @@ -215,7 +215,7 @@ func (o *OTelMetrics) Register(name string, metricType string) {
}
o.gauges[name] = g
case "histogram":
h, err := o.meter.Int64Histogram(name)
h, err := o.meter.Float64Histogram(name)
if err != nil {
o.Logger.Error().WithString("msg", "failed to create histogram").WithString("name", name)
return
Expand Down Expand Up @@ -268,7 +268,7 @@ func (o *OTelMetrics) Histogram(name string, val interface{}) {

if h, ok := o.histograms[name]; ok {
f := ConvertNumeric(val)
h.Record(context.Background(), int64(f))
h.Record(context.Background(), f)
o.values[name] += f
}
}
Expand Down
Loading