Skip to content

Instantly share code, notes, and snippets.

@Antonboom
Last active August 15, 2019 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Antonboom/fbabc0c3322329ee7ba97deef116c5b3 to your computer and use it in GitHub Desktop.
Save Antonboom/fbabc0c3322329ee7ba97deef116c5b3 to your computer and use it in GitHub Desktop.
[Go] Prometheus + gin router
import (
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
// ...
{
r := gin.New()
r.GET("/metrics", func() gin.HandlerFunc {
h := promhttp.Handler()
return func(c *gin.Context) {
h.ServeHTTP(c.Writer, c.Request)
}
}())
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment