segmentio / stats

Go package for abstracting stats collection
https://godoc.org/github.com/segmentio/stats
MIT License
208 stars 32 forks source link

Automatically register prometheus handler to the default http mux? #43

Closed achille-roussel closed 7 years ago

achille-roussel commented 7 years ago

@f2prateek @yields @abraithwaite

What do you guys think about making the prometheus handler automatically register to the default http mux when github.com/segmentio/stats/prometheus is imported?

Basically adding this to the prometheus package:

func init() {
    http.Handle("/metrics", DefaultHandler)
}
abraithwaite commented 7 years ago

I don't see any immediate issues with it but I don't like registering stuff with the default handler especially in an opaque and non-reversible way.

No surprises.

f2prateek commented 7 years ago

Why is this required/needed?

I'd be against this as a default, /metrics is somewhat generic (e.g. we use it in the metrics.segment.com service).

If it must, maybe as a more explicit import in a subpackage - import _ "..../promethues/handler" (though at that point you might as well call http.Handle yourself as well).

achille-roussel commented 7 years ago

/metrics is the standard endpoint for prometheus.

This change would be for convenience, if you have to import another package to replace one line of code it seems like it's not really worth it :P

f2prateek commented 7 years ago

Also just thinking that if an external service were to be using this, this would implicitly expose /metrics externally? That doesn't seem like the best idea.

achille-roussel commented 7 years ago

Alright you convinced me, that's a bad idea 😛

Thanks for your input guys!