go-martini / martini

Classy web framework for Go
martini.codegangsta.io
MIT License
11.63k stars 1.1k forks source link

Add support for promhttp #417

Open jeffreyyong opened 5 years ago

jeffreyyong commented 5 years ago

InstrumentHandlerResponseSize func(obs prometheus.ObserverVec, next http.Handler) http.Handler from the promhttp package takes in "http.Handler" and returns a "http.Handler" for instrumenting the response size. However, martini only has martini.Handler which makes it impossible to pass into the promhttp instrumentation function, I'm wondering if it's possible to use martini with prometheus promhttp?

jeffreyyong commented 5 years ago

Manage to make the Go programme compile, but when it's done like this:

m := martini.New()
m.Use(promhttp.InstrumentHandlerInFlight(metrics.RequestGauge, m))

The whole programme just gets stuck

zoidyzoidzoid commented 5 years ago

I was recently looking at adding opencensus instrumentation to orchestrator which uses Martini too. It suggests doing it passing in a custom http.Handler too here

Though I'm looking at writing my own middleware for it instead.