{"record":{"id":"5faea9c73fa75370","repo":"grafana/k6","slug":"metric-q-is-not-a-histogram","errorCode":null,"errorMessage":"metric %q is not a histogram","messagePattern":"metric %q is not a histogram","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/output/opentelemetry/registry.go","lineNumber":61,"sourceCode":"\n\tc, err := r.meter.Float64Counter(name, opts...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create counter for %q: %w\", name, err)\n\t}\n\n\tr.logger.Debugf(\"registered counter metric %q\", name)\n\n\tr.counters.Store(name, c)\n\treturn c, nil\n}\n\nfunc (r *registry) getOrCreateHistogram(name, unit string) (otelMetric.Float64Histogram, error) {\n\tif histogram, ok := r.histograms.Load(name); ok {\n\t\tif v, ok := histogram.(otelMetric.Float64Histogram); ok {\n\t\t\treturn v, nil\n\t\t}\n\n\t\treturn nil, fmt.Errorf(\"metric %q is not a histogram\", name)\n\t}\n\n\topts := []otelMetric.Float64HistogramOption{}\n\tif unit != \"\" {\n\t\topts = append(opts, otelMetric.WithUnit(unit))\n\t}\n\n\th, err := r.meter.Float64Histogram(name, opts...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create histogram for %q: %w\", name, err)\n\t}\n\n\tr.logger.Debugf(\"registered histogram metric %q\", name)\n\n\tr.histograms.Store(name, h)\n\treturn h, nil\n}\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/output/opentelemetry/registry.go#L43-L79","documentation":"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.","triggerScenarios":"Thrown at internal/output/opentelemetry/registry.go:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the metric to avoid a counter/gauge/histogram name collision","Ensure Trend metrics don't share names with Counter/Gauge metrics"],"exampleFix":null,"handlingStrategy":"type-guard","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-14T00:17:10.932Z"}