{"record":{"id":"86de8a4a14d17379","repo":"thanos-io/thanos","slug":"unsupported-metric-type","errorCode":null,"errorMessage":"unsupported metric type","messagePattern":"unsupported metric type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/otlptranslator/metrics_to_prw.go","lineNumber":170,"sourceCode":"\t\t\t\t\t\terrs.Add(err)\n\t\t\t\t\t\tif errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tcase pmetric.MetricTypeSummary:\n\t\t\t\t\tdataPoints := metric.Summary().DataPoints()\n\t\t\t\t\tif dataPoints.Len() == 0 {\n\t\t\t\t\t\terrs.Add(fmt.Errorf(\"empty data points. %s is dropped\", metric.Name()))\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tif err := c.addSummaryDataPoints(ctx, dataPoints, resource, settings, promName); err != nil {\n\t\t\t\t\t\terrs.Add(err)\n\t\t\t\t\t\tif errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\terrs.Add(errors.New(\"unsupported metric type\"))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\taddResourceTargetInfo(resource, settings, mostRecentTimestamp, c)\n\t}\n\n\treturn annots, errs\n}\n\nfunc isSameMetric(ts *prompb.TimeSeries, lbls []labelpb.ZLabel) bool {\n\tif len(ts.Labels) != len(lbls) {\n\t\treturn false\n\t}\n\tfor i, l := range ts.Labels {\n\t\tif l.Name != ts.Labels[i].Name || l.Value != ts.Labels[i].Value {\n\t\t\treturn false\n\t\t}\n\t}","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/otlptranslator/metrics_to_prw.go#L152-L188","documentation":"FromMetrics switches over pmetric.MetricType and every known case (Gauge, Sum, Histogram, ExponentialHistogram, Summary) is handled; hitting the default branch means the payload carries a metric type this translator does not recognize — either a newer OTLP metric type than this Prometheus build supports, or a corrupted/zero-value Metric.","triggerScenarios":"An OTLP export contains a Metric whose Type() is a newer enum value (e.g. a future pmetric type) not compiled into this Prometheus version, or a nil/unset metric in the slice.","commonSituations":"Version skew: newer OpenTelemetry collector or SDK exporting metric types the receiving Prometheus predates; corrupted OTLP payloads; manually constructed pmetric slices with unset type.","solutions":["Upgrade Prometheus to a version whose pmetric library supports the new metric type","Check the OTLP producer's version and disable the unsupported metric type there","Verify the OTLP payload is not corrupted (re-encode/re-send)","Confirm no manually built pmetric.Metric is left with an unset type"],"exampleFix":"// before\n// prometheus built against older pmetrics, producer sends new type\n// after\n// go get go.opentelemetry.io/collector/pdata@latest && upgrade prometheus\n// or drop the new type on the collector:\n// transform processor: delete_metric where metric.type == \"new_type\"","handlingStrategy":"validation","validationCode":"// pre-check metric types against what this Prometheus supports:\nsupported := map[pmetric.MetricType]bool{\n    pmetric.MetricTypeGauge: true, pmetric.MetricTypeSum: true,\n    pmetric.MetricTypeHistogram: true, pmetric.MetricTypeExponentialHistogram: true,\n    pmetric.MetricTypeSummary: true,\n}\nfor i := 0; i < metrics.Len(); i++ {\n    if !supported[metrics.At(i).Type()] { log.Warn(\"unsupported metric type, dropping\", metrics.At(i).Name()) }\n}","typeGuard":"func isSupportedMetricType(m pmetric.Metric) bool {\n    switch m.Type() {\n    case pmetric.MetricTypeGauge, pmetric.MetricTypeSum, pmetric.MetricTypeHistogram,\n        pmetric.MetricTypeExponentialHistogram, pmetric.MetricTypeSummary:\n        return true\n    }\n    return false\n}","tryCatchPattern":"errs := translator.FromMetrics(ctx, metrics, ...)\nif errs != nil {\n    for _, err := range errs.Errors() {\n        if strings.Contains(err.Error(), \"unsupported metric type\") {\n            log.Warn(\"unsupported metric type; upgrade Prometheus or drop at collector\", \"err\", err)\n        }\n    }\n}","preventionTips":["Keep the pmetric dependency and Prometheus versions in sync","Drop unsupported types at the collector with a transform processor","Pin producer SDK versions in tests"],"tags":["otlp","metrics","version-skew"],"backgroundTag":"unsupported-enum-value","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}