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: panic when multiple hcloud-go Client with Instrumentation are registered #288

Closed
apricote opened this issue Jul 14, 2023 · 0 comments · Fixed by #289
Closed

fix: panic when multiple hcloud-go Client with Instrumentation are registered #288

apricote opened this issue Jul 14, 2023 · 0 comments · Fixed by #289
Assignees
Labels

Comments

@apricote
Copy link
Member

If one creates multiple Clients WithInstrumentation on the same registry, this will cause a panic because the Collectors (by name) are already defined from a previous Client.

panic: duplicate metrics collector registration attempted

goroutine 16 [running]:
github.com/prometheus/client_golang/prometheus.(*Registry).MustRegister(...)
	/home/x/go/pkg/mod/github.com/prometheus/client_golang@v1.16.0/prometheus/registry.go:405
github.com/hetznercloud/hcloud-go/v2/hcloud/internal/instrumentation.(*Instrumenter).InstrumentedRoundTripper(0xc0001bbcf0)
	/home/x/go/pkg/mod/github.com/hetznercloud/hcloud-go/v2@v2.0.0/hcloud/internal/instrumentation/metrics.go:48 +0x785
github.com/hetznercloud/hcloud-go/v2/hcloud.NewClient({0xc0001bbd98, 0x3, 0x10?})
	/home/x/go/pkg/mod/github.com/hetznercloud/hcloud-go/v2@v2.0.0/hcloud/client.go:189 +0x273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant