{"record":{"id":"89655ea16ab51e36","repo":"grafana/k6","slug":"failed-to-create-gauge-for-q-w","errorCode":null,"errorMessage":"failed to create gauge for %q: %w","messagePattern":"failed to create gauge for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/output/opentelemetry/registry.go","lineNumber":126,"sourceCode":"}\n\nfunc (r *registry) getOrCreateGauge(name, unit string) (otelMetric.Float64Gauge, error) {\n\tif gauge, ok := r.gauges.Load(name); ok {\n\t\tif v, ok := gauge.(otelMetric.Float64Gauge); ok {\n\t\t\treturn v, nil\n\t\t}\n\n\t\treturn nil, fmt.Errorf(\"metric %q is not a gauge\", name)\n\t}\n\n\topts := []otelMetric.Float64GaugeOption{}\n\tif unit != \"\" {\n\t\topts = append(opts, otelMetric.WithUnit(unit))\n\t}\n\n\tgauge, err := r.meter.Float64Gauge(name, opts...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create gauge for %q: %w\", name, err)\n\t}\n\n\tr.logger.Debugf(\"registered gauge metric %q \", name)\n\n\tr.gauges.Store(name, gauge)\n\treturn gauge, nil\n}\n","sourceCodeStart":108,"sourceCodeEnd":134,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/output/opentelemetry/registry.go#L108-L134","documentation":"When a gauge is not yet cached, getOrCreateGauge calls meter.Float64Gauge to create it; an error here (wrapped with the metric name) comes from the OpenTelemetry meter — typically an invalid metric name/unit per OTel semantics. It aborts dispatch of that metric to the exporter.","triggerScenarios":"Thrown at internal/output/opentelemetry/registry.go:126 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error from the meter provider","Use a unique metric name for the gauge instrument"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}