Add Prometheus metrics

This commit is contained in:
Jacob Gunther
2022-03-24 04:02:37 -05:00
parent baed581d69
commit d9feff6c4b
10 changed files with 598 additions and 7 deletions

View File

@@ -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 {