valyala / fasthttp

Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
MIT License
21.91k stars 1.76k forks source link

Support for Prometheus #1736

Open gaby opened 8 months ago

gaby commented 8 months ago

@erikdubbelboer I notice multiple Prometheus solutions for fasthttp are just using the fasthttp adaptor to handle calling the prometheus net/http handler.

I did some googling at there was an issue opened in the Prometheus Golang Client back in 2017. Basically the promhttp will have to be converted to promfasthttp to allow fasthttp have native prometheus.

Someone created a draft of this back in 2017 but it's way out of date. That draft can be found here: https://github.com/krisdioles/client_golang/commit/20b36c81f36ef6ea5b25d5a531d08689d22ba7cd

The current promhttp can be found here (this one would need to be converted to fasthttp): https://github.com/prometheus/client_golang/blob/main/prometheus/promhttp/http.go

I reached out to the Prometheus dev but they suggested this should be handle in this repo or in the prometheus-community as a new module or I can host a module if that also helps get this done.

Discussion here: https://github.com/prometheus/client_golang/issues/356

I figured posting here and asking you if this is something the fasthttp team can do to integrate Prometheus metrics into fasthttp. This will greatly enhance the fasthttp ecosystem as a whole.

erikdubbelboer commented 8 months ago

I'm afraid I don't have time to do that. But a pull request is of course always welcome!

ksw2000 commented 3 months ago

Hello @gaby, in concrete terms, what features should be implemented in fasthttp to integrate with Prometheus?

gaby commented 3 months ago

@ksw2000 The promhttp has to be converted to fasthttp, although It probably had to go in a separate module to not force the dependecies on everyone.

The code is here https://github.com/prometheus/client_golang/blob/main/prometheus/promhttp/http.go

The current solution is to use fasthttp adaptor. Which is probably good enough