From 7871bcb4653f15bb6f74654ed256dca3548cddc6 Mon Sep 17 00:00:00 2001 From: Naman-B-Parlecha Date: Tue, 7 Oct 2025 14:20:32 +0530 Subject: [PATCH] fix(convert): error message Signed-off-by: Naman-B-Parlecha --- model/histogram/convert.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/model/histogram/convert.go b/model/histogram/convert.go index 250289c8d2..19376db93c 100644 --- a/model/histogram/convert.go +++ b/model/histogram/convert.go @@ -15,6 +15,7 @@ package histogram import ( "errors" + "fmt" "math" "github.com/prometheus/prometheus/model/labels" @@ -40,8 +41,8 @@ func ConvertNHCBToClassic(nhcb any, lset labels.Labels, lsetBuilder *labels.Buil switch h := nhcb.(type) { case *Histogram: - if h.Schema != -53 { - return errors.New("unsupported histogram schema, only NHCB conversion is supported") + if !IsCustomBucketsSchema(h.Schema) { + return errors.New("unsupported histogram schema, not a NHCB") } customValues = h.CustomValues positiveBuckets = make([]float64, len(h.PositiveBuckets)) @@ -55,15 +56,15 @@ func ConvertNHCBToClassic(nhcb any, lset labels.Labels, lsetBuilder *labels.Buil count = float64(h.Count) sum = h.Sum case *FloatHistogram: - if h.Schema != -53 { - return errors.New("unsupported histogram schema, only NHCB conversion is supported") + if !IsCustomBucketsSchema(h.Schema) { + return errors.New("unsupported histogram schema, not a NHCB") } customValues = h.CustomValues positiveBuckets = h.PositiveBuckets count = h.Count sum = h.Sum default: - return errors.New("unsupported histogram type") + return fmt.Errorf("unsupported histogram type: %T", h) } // Each customValue corresponds to a positive bucket (aligned with the "le" label).