Skip to content

Commit 851eeb4

Browse files
Merge pull request #155 from kaleido-io/metric-collector
[pkg/metric] - Add the ability to register a new metrics collector to the registry
2 parents 0bd135d + 04b5501 commit 851eeb4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/metric/metric.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2023 Kaleido, Inc.
1+
// Copyright © 2024 Kaleido, Inc.
22
//
33
// SPDX-License-Identifier: Apache-2.0
44
//
@@ -58,6 +58,8 @@ type MetricsRegistry interface {
5858
NewHTTPMetricsInstrumentationsForSubsystem(ctx context.Context, subsystem string, useRouteTemplate bool, reqDurationBuckets []float64, labels map[string]string) error
5959
// GetHTTPMetricsInstrumentationsMiddlewareForSubsystem returns the HTTP middleware of a subsystem that used predefined HTTP metrics
6060
GetHTTPMetricsInstrumentationsMiddlewareForSubsystem(ctx context.Context, subsystem string) (func(next http.Handler) http.Handler, error)
61+
62+
MustRegisterCollector(collector prometheus.Collector)
6163
}
6264

6365
type FireflyDefaultLabels struct {
@@ -185,3 +187,7 @@ func (pmr *prometheusMetricsRegistry) GetHTTPMetricsInstrumentationsMiddlewareFo
185187
}
186188
return httpInstrumentation.Middleware, nil
187189
}
190+
191+
func (pmr *prometheusMetricsRegistry) MustRegisterCollector(collector prometheus.Collector) {
192+
pmr.registerer.MustRegister(collector)
193+
}

0 commit comments

Comments
 (0)