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

Deprecate metrics.Default #3026

Open
AlexanderYastrebov opened this issue Apr 19, 2024 · 0 comments
Open

Deprecate metrics.Default #3026

AlexanderYastrebov opened this issue Apr 19, 2024 · 0 comments

Comments

@AlexanderYastrebov
Copy link
Member

Is your feature request related to a problem? Please describe.

There are quite a few places that rely on global metrics.Default variable

skipper/metrics/metrics.go

Lines 199 to 202 in 0ce11b9

var (
Default Metrics
Void Metrics
)

This is a bad design which is not thread-safe and complicates tests, e.g.:

func TestMetricsUncompressed(t *testing.T) {
dm := metrics.Default
t.Cleanup(func() { metrics.Default = dm })
m := &metricstest.MockMetrics{}
metrics.Default = m

Describe the solution you would like

Components that update metrics receive metrics instance via configuration.
First we may refactor components to make metrics configurable and fallback to metrics.Default for backwards compatibility.
Then deprecate and later remove metrics.Default completely.

Would you like to work on it?

Yes

AlexanderYastrebov added a commit that referenced this issue Apr 19, 2024
Use configed metrics and fallback to global for backwards compatibility.

Updates #3026

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
AlexanderYastrebov added a commit that referenced this issue Apr 22, 2024
Use configed metrics and fallback to global for backwards compatibility.

Updates #3026

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant