{"record":{"id":"c33c85c976b56d14","repo":"grafana/k6","slug":"failed-to-create-histogram-for-q-w","errorCode":null,"errorMessage":"failed to create histogram for %q: %w","messagePattern":"failed to create histogram for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/output/opentelemetry/registry.go","lineNumber":71,"sourceCode":"}\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\nfunc (r *registry) getOrCreateCounterForRate(name string) (otelMetric.Int64Counter, error) {\n\t// k6's rate metric tracks how frequently a non-zero value occurs.\n\t// To be accurate is a percentage, which is a ratio.\n\t// To correctly calculate this metric in a metrics backend,\n\t// we need to split the rate metric via a dedicated attribute.\n\n\ttotalName := name + \".total\"\n\n\tvar err error\n\tvar totalCounter otelMetric.Int64Counter","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/output/opentelemetry/registry.go#L53-L89","documentation":"The OTel Meter rejected creation of a Float64Histogram instrument for this metric name. getOrCreateHistogram wraps the SDK error, typically a name conflict with an existing instrument of another kind.","triggerScenarios":"Thrown at internal/output/opentelemetry/registry.go:71 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 histogram"],"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"}