diff --git a/pkg/infra/metrics/service.go b/pkg/infra/metrics/service.go index 3a964dfc58f..f704ab9248b 100644 --- a/pkg/infra/metrics/service.go +++ b/pkg/infra/metrics/service.go @@ -144,10 +144,10 @@ func (r *multiRegistry) Gather() (mfs []*dto.MetricFamily, err error) { _, exists := names[*m.Name] // prevent duplicate metric names if exists { - // we can skip go_ metrics without returning an error + // we can skip go_ and process_ metrics without returning an error // because they are known to be duplicates in both // the k8s and prometheus gatherers. - if strings.HasPrefix(*m.Name, "go_") { + if strings.HasPrefix(*m.Name, "go_") || strings.HasPrefix(*m.Name, "process_") { continue } errs = append(errs, fmt.Errorf("duplicate metric name: %s", *m.Name)) diff --git a/pkg/infra/metrics/service_test.go b/pkg/infra/metrics/service_test.go index 6d32dde6480..4ee13be81b2 100644 --- a/pkg/infra/metrics/service_test.go +++ b/pkg/infra/metrics/service_test.go @@ -99,12 +99,13 @@ func TestMultiRegistry_Gather(t *testing.T) { require.Error(t, err) }) - t.Run("duplicate go_ prefixed metrics do not result in an error", func(t *testing.T) { + t.Run("duplicate go_ or process_ prefixed metrics do not result in an error", func(t *testing.T) { one.GatherFunc = func() ([]*dto.MetricFamily, error) { return []*dto.MetricFamily{ {Name: strptr("b")}, {Name: strptr("a")}, {Name: strptr("go_a")}, + {Name: strptr("process_a")}, }, nil } @@ -113,6 +114,7 @@ func TestMultiRegistry_Gather(t *testing.T) { {Name: strptr("d")}, {Name: strptr("c")}, {Name: strptr("go_a")}, + {Name: strptr("process_a")}, }, nil } @@ -122,6 +124,7 @@ func TestMultiRegistry_Gather(t *testing.T) { {Name: strptr("c")}, {Name: strptr("d")}, {Name: strptr("go_a")}, + {Name: strptr("process_a")}, } mf, err := g.Gather()