Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(metrics): do not use shared DefaultRegistry and fix wg.Done call #543

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions bootstrap/metrics/manager.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2022 Intel Corp.
* Copyright 2022-2023 Intel Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -51,7 +51,7 @@ func (m *manager) ResetInterval(interval time.Duration) {
func NewManager(lc logger.LoggingClient, interval time.Duration, reporter interfaces.MetricsReporter) interfaces.MetricsManager {
m := &manager{
lc: lc,
registry: gometrics.DefaultRegistry,
registry: gometrics.NewRegistry(),
reporter: reporter,
interval: interval,
metricTags: make(map[string]map[string]string),
Expand Down Expand Up @@ -100,9 +100,10 @@ func (m *manager) Run(ctx context.Context, wg *sync.WaitGroup) {
m.ticker = time.NewTicker(m.interval)

wg.Add(1)
defer wg.Done()

go func() {
defer wg.Done()

for {
select {
case <-ctx.Done():
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/metrics/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestMessageBusReporter_Report(t *testing.T) {
expectedTags)
require.NoError(t, err)

reg := gometrics.DefaultRegistry
reg := gometrics.NewRegistry()

counter := gometrics.NewCounter()
counter.Inc(intValue)
Expand Down