diff --git a/metrics/prometheus/prometheus.go b/metrics/prometheus/prometheus.go index bfa73245c9..9db1495af8 100644 --- a/metrics/prometheus/prometheus.go +++ b/metrics/prometheus/prometheus.go @@ -57,7 +57,8 @@ func (g *Gatherer) Gather() (mfs []*dto.MetricFamily, err error) { } var ( - errMetricSkip = errors.New("metric skipped") + errMetricSkip = errors.New("metric skipped") + errMetricTypeNotSupported = errors.New("metric type is not supported") ) func ptrTo[T any](x T) *T { return &x } @@ -197,7 +198,10 @@ func metricFamily(registry Registry, name string) (mf *dto.MetricFamily, err err }, }}, }, nil + case metrics.GaugeInfo: + // TODO(qdm12) handle this somehow maybe with dto.MetricType_UNTYPED + return nil, fmt.Errorf("%w: %q is a %T", errMetricSkip, name, metric) default: - return nil, fmt.Errorf("metric %q: type is not supported: %T", name, metric) + return nil, fmt.Errorf("%w: metric %q type %T", errMetricTypeNotSupported, name, metric) } } diff --git a/metrics/prometheus/prometheus_test.go b/metrics/prometheus/prometheus_test.go index 4263abed7d..71d506efa5 100644 --- a/metrics/prometheus/prometheus_test.go +++ b/metrics/prometheus/prometheus_test.go @@ -90,8 +90,8 @@ func TestGatherer_Gather(t *testing.T) { } assert.Equal(t, want, familyStrings) - register(t, "unsupported", metrics.NewGaugeInfo()) + register(t, "unsupported", metrics.NewHealthcheck(nil)) families, err = gatherer.Gather() - assert.EqualError(t, err, "metric \"unsupported\": type is not supported: *metrics.StandardGaugeInfo") + assert.ErrorIs(t, err, errMetricTypeNotSupported) assert.Empty(t, families) }