-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add metrics collector #87
Conversation
See libp2p/go-libp2p-kad-dht#297 and anacrolix/go-libp2p-dht-tool#2 where we're working on similar things. |
p2pd/main.go
Outdated
@@ -208,5 +211,10 @@ func main() { | |||
} | |||
} | |||
|
|||
if *metricsAddr != "" { | |||
http.Handle("/metrics", prometheus.Handler()) | |||
go log.Println(http.ListenAndServe(*metricsAddr, nil)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this Println doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the http server terminates with an error, it will be logged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine, but I am a little confused by the semantics of this. It seems that only the Println
will be executed in the goroutine, the listenAndServe
will be synchronous -- which isn't what you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhhh i think the entire block is run asynchronously but i need to confirm. let me test. thanks for pointing it out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep you nailed it. fixed.
p2pd/main.go
Outdated
multiaddr "github.com/multiformats/go-multiaddr" | ||
"github.com/libp2p/go-libp2p/p2p/protocol/identify" | ||
"github.com/multiformats/go-multiaddr" | ||
"github.com/prometheus/client_golang/prometheus/promhttp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happened to the named imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lord have mercy i'm trying out goland since gocode is so slow right now and now i'm suffering the same fate
This will be used by testbed, but is disabled by default. Exposes an http endpoint prometheus can scrape to gather metrics. For now, I like using prometheus directly as it provides us with a much richer API for instrumenting code. If there is a strong desire to use our stripped down go-metrics-interface, I'm happy to, though I'd like to add annotation support.