grafana/k6 · error
metric %q is not a histogram
Error message
metric %q is not a histogram
What it means
The OTel registry found an instrument cached under this metric name, but its dynamic type is not Float64Histogram — another instrument kind (counter/gauge) already occupies this name in the histograms map.
Source
Thrown at internal/output/opentelemetry/registry.go:61
c, err := r.meter.Float64Counter(name, opts...)
if err != nil {
return nil, fmt.Errorf("failed to create counter for %q: %w", name, err)
}
r.logger.Debugf("registered counter metric %q", name)
r.counters.Store(name, c)
return c, nil
}
func (r *registry) getOrCreateHistogram(name, unit string) (otelMetric.Float64Histogram, error) {
if histogram, ok := r.histograms.Load(name); ok {
if v, ok := histogram.(otelMetric.Float64Histogram); ok {
return v, nil
}
return nil, fmt.Errorf("metric %q is not a histogram", name)
}
opts := []otelMetric.Float64HistogramOption{}
if unit != "" {
opts = append(opts, otelMetric.WithUnit(unit))
}
h, err := r.meter.Float64Histogram(name, opts...)
if err != nil {
return nil, fmt.Errorf("failed to create histogram for %q: %w", name, err)
}
r.logger.Debugf("registered histogram metric %q", name)
r.histograms.Store(name, h)
return h, nil
}
View on GitHub (pinned to 01ffac6f24)
Solutions
- Rename the metric to avoid a counter/gauge/histogram name collision
- Ensure Trend metrics don't share names with Counter/Gauge metrics
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/output/opentelemetry/registry.go:61 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/5faea9c73fa75370.
Report an issue: GitHub.