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: TestCreateCollectorProxy unit test failing on go-tip #6204

Merged
Merged
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
17 changes: 11 additions & 6 deletions cmd/agent/app/reporter/connect_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package reporter

import (
"expvar"
"sync"

"github.com/jaegertracing/jaeger/pkg/metrics"
)
Expand All @@ -23,17 +24,21 @@ type ConnectMetrics struct {
target *expvar.String
}

var (
gRPCTarget *expvar.String
gRPCTargetOnce sync.Once
)

// NewConnectMetrics will be initialize ConnectMetrics
func NewConnectMetrics(mf metrics.Factory) *ConnectMetrics {
cm := &ConnectMetrics{}
metrics.MustInit(&cm.metrics, mf.Namespace(metrics.NSOptions{Name: "connection_status"}), nil)

if r := expvar.Get("gRPCTarget"); r == nil {
cm.target = expvar.NewString("gRPCTarget")
} else {
cm.target = r.(*expvar.String)
}

// expvar.String is not thread-safe, so we need to initialize it only once
gRPCTargetOnce.Do(func() {
gRPCTarget = expvar.NewString("gRPCTarget")
})
cm.target = gRPCTarget
return cm
}

Expand Down
Loading