Have you read a contributing guide?
Current Behavior
Hi,
Thanks for project ❤️
I am creating a build of an Anytype all-in-one, and one of the issues that I encountered was that some components register themselves globally, like metrics. You can't create two separate App instances and register them to separate metrics because they are using a global HTTP package.
Problem line -
|
http.Handle("/metrics", promhttp.HandlerFor(m.registry, promhttp.HandlerOpts{})) |
Error:
// ...
panic: pattern "/metrics" (registered at /Users/grishy/go/pkg/mod/github.com/anyproto/any-sync@v0.5.22/metric/metric.go:107) conflicts with pattern "/metrics" (registered at /Users/grishy/go/pkg/mod/github.com/anyproto/any-sync@v0.5.22/metric/metric.go:107):
/metrics matches the same requests as /metrics
goroutine 1 [running]:
net/http.(*ServeMux).register(...)
/opt/homebrew/Cellar/go/1.23.5/libexec/src/net/http/server.go:2797
net/http.Handle({0x104c7abfb?, 0x0?}, {0x105272e60?, 0x14000256cc0?})
/opt/homebrew/Cellar/go/1.23.5/libexec/src/net/http/server.go:2781 +0x98
github.com/anyproto/any-sync/metric.(*metric).Run(0x140004d1d40, {0x1051cf9c0?, 0x1400050e880?})
/Users/grishy/go/pkg/mod/github.com/anyproto/any-sync@v0.5.22/metric/metric.go:107 +0x18c
github.com/anyproto/any-sync/app.(*App).Start(0x14000a12120, {0x10527d590, 0x140008e8200})
/Users/grishy/go/pkg/mod/github.com/anyproto/any-sync@v0.5.22/app/app.go:262 +0x490
main.main()
/Users/grishy/personal/github/any-sync-bundle/main.go:35 +0x188
exit status 2
I want to ask for a way that you think would be better so I can create a PR.
Thx!
Expected Behavior
Allow specifying the path for metrics if they are registered globally to avoid conflicts or to merge metrics properly
Steps To Reproduce
Create two apps with separate instances of metric.
Environment
Anything else?
No response
Have you read a contributing guide?
Current Behavior
Hi,
Thanks for project ❤️
I am creating a build of an Anytype all-in-one, and one of the issues that I encountered was that some components register themselves globally, like metrics. You can't create two separate App instances and register them to separate metrics because they are using a global HTTP package.
Problem line -
any-sync/metric/metric.go
Line 107 in 7e98393
Error:
I want to ask for a way that you think would be better so I can create a PR.
Thx!
Expected Behavior
Allow specifying the path for metrics if they are registered globally to avoid conflicts or to merge metrics properly
Steps To Reproduce
Create two apps with separate instances of
metric.Environment
Anything else?
No response