Skip to content

Commit a22898c

Browse files
fix: resolve breaking API changes
1 parent e1bb260 commit a22898c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/pkg/api/metrics.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111
"sync"
1212

13+
"github.com/gofrs/uuid/v5"
1314
"github.com/prometheus/client_golang/prometheus"
1415
"github.com/prometheus/client_golang/prometheus/promhttp"
1516
"github.com/rs/zerolog"
@@ -55,7 +56,17 @@ var (
5556
// metrics must be explicitly exposed with a call to InitMetrics
5657
// FIXME we have global metrics but an internal and external API; this may lead to some confusion.
5758
func init() {
58-
err := report.SetupMetrics(logger.NewZapStub("instance-metrics"), build.ServiceName, version.DefaultVersion)
59+
// maintain original behaviour from deprecated report.SetupMetrics
60+
ephemeralID, _ := uuid.NewV4()
61+
err := report.SetupMetricsOptions(report.MetricOptions{
62+
Name: build.ServiceName,
63+
Version: version.DefaultVersion,
64+
EphemeralID: ephemeralID.String(),
65+
Logger: logger.NewZapStub("instance-metrics"),
66+
SystemMetrics: monitoring.Default.GetOrCreateRegistry("system"),
67+
ProcessMetrics: monitoring.Default.GetOrCreateRegistry("beat"),
68+
})
69+
5970
if err != nil {
6071
zerolog.Ctx(context.TODO()).Error().Err(err).Msg("unable to initialize metrics") // TODO is used because this may logged during the package load
6172
}

0 commit comments

Comments
 (0)