Add Prometheus metrics
This commit is contained in:
@@ -7,9 +7,18 @@ import (
|
||||
|
||||
"github.com/mineatar-io/api-server/src/util"
|
||||
"github.com/mineatar-io/skin-render"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"github.com/valyala/fasthttp"
|
||||
)
|
||||
|
||||
var (
|
||||
renderHeadMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "head_render_count",
|
||||
Help: "The amount of head renders",
|
||||
})
|
||||
)
|
||||
|
||||
func HeadHandler(ctx *fasthttp.RequestCtx) {
|
||||
user := ctx.UserValue("user").(string)
|
||||
|
||||
@@ -85,6 +94,8 @@ func HeadHandler(ctx *fasthttp.RequestCtx) {
|
||||
log.Printf("Rendered head image for '%s'\n", uuid)
|
||||
}
|
||||
|
||||
renderHeadMetric.Inc()
|
||||
|
||||
data, err := util.EncodePNG(render)
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user