grafana/k6 · error
metric %q is not a gauge
Error message
metric %q is not a gauge
What it means
getOrCreateGauge looks up the name in the gauges sync.Map and type-asserts to otelMetric.Float64Gauge. If a value exists but is not a gauge, the same metric name was registered earlier as another instrument type; a naming collision in registry state makes dispatch fail. Internal consistency error, not user-caused.
Source
Thrown at internal/output/opentelemetry/registry.go:116
r.rateCounters.Store(totalName, totalCounter)
r.logger.Debugf("registered counter metric %q", totalName)
} else {
totalCounter, ok = storedTotalCounter.(otelMetric.Int64Counter)
if !ok {
return nil, fmt.Errorf("metric %q stored not as counter", totalName)
}
}
return totalCounter, nil
}
func (r *registry) getOrCreateGauge(name, unit string) (otelMetric.Float64Gauge, error) {
if gauge, ok := r.gauges.Load(name); ok {
if v, ok := gauge.(otelMetric.Float64Gauge); ok {
return v, nil
}
return nil, fmt.Errorf("metric %q is not a gauge", name)
}
opts := []otelMetric.Float64GaugeOption{}
if unit != "" {
opts = append(opts, otelMetric.WithUnit(unit))
}
gauge, err := r.meter.Float64Gauge(name, opts...)
if err != nil {
return nil, fmt.Errorf("failed to create gauge for %q: %w", name, err)
}
r.logger.Debugf("registered gauge metric %q ", name)
r.gauges.Store(name, gauge)
return gauge, nil
}
View on GitHub (pinned to 01ffac6f24)
Solutions
- Rename the gauge metric to avoid name collisions with counters/histograms
- Use distinct names per metric type
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/output/opentelemetry/registry.go:116 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/8558fbc7d6f41781.
Report an issue: GitHub.