Add more metrics
This commit is contained in:
@@ -13,22 +13,42 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
requestFullBodyMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "full_body_request_count",
|
||||
Help: "The amount of full body requests",
|
||||
})
|
||||
renderFullBodyMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "full_body_render_count",
|
||||
Help: "The amount of full body renders",
|
||||
})
|
||||
requestFrontBodyMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "front_body_request_count",
|
||||
Help: "The amount of front body requests",
|
||||
})
|
||||
renderFrontBodyMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "front_body_render_count",
|
||||
Help: "The amount of front body renders",
|
||||
})
|
||||
requestBackBodyMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "back_body_request_count",
|
||||
Help: "The amount of back body requests",
|
||||
})
|
||||
renderBackBodyMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "back_body_render_count",
|
||||
Help: "The amount of back body renders",
|
||||
})
|
||||
requestLeftBodyMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "left_body_request_count",
|
||||
Help: "The amount of left body requests",
|
||||
})
|
||||
renderLeftBodyMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "left_body_render_count",
|
||||
Help: "The amount of left body renders",
|
||||
})
|
||||
requestRightBodyMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "right_body_request_count",
|
||||
Help: "The amount of right body requests",
|
||||
})
|
||||
renderRightBodyMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "right_body_render_count",
|
||||
Help: "The amount of right body renders",
|
||||
@@ -36,6 +56,8 @@ var (
|
||||
)
|
||||
|
||||
func FullBodyHandler(ctx *fasthttp.RequestCtx) {
|
||||
requestFullBodyMetric.Inc()
|
||||
|
||||
user := ctx.UserValue("user").(string)
|
||||
|
||||
opts := util.ParseQueryParams(ctx, config.Routes.FullBody)
|
||||
@@ -142,6 +164,8 @@ func FullBodyHandler(ctx *fasthttp.RequestCtx) {
|
||||
}
|
||||
|
||||
func FrontBodyHandler(ctx *fasthttp.RequestCtx) {
|
||||
requestFrontBodyMetric.Inc()
|
||||
|
||||
user := ctx.UserValue("user").(string)
|
||||
|
||||
opts := util.ParseQueryParams(ctx, config.Routes.FrontBody)
|
||||
@@ -248,6 +272,8 @@ func FrontBodyHandler(ctx *fasthttp.RequestCtx) {
|
||||
}
|
||||
|
||||
func BackBodyHandler(ctx *fasthttp.RequestCtx) {
|
||||
requestBackBodyMetric.Inc()
|
||||
|
||||
user := ctx.UserValue("user").(string)
|
||||
|
||||
opts := util.ParseQueryParams(ctx, config.Routes.BackBody)
|
||||
@@ -354,6 +380,8 @@ func BackBodyHandler(ctx *fasthttp.RequestCtx) {
|
||||
}
|
||||
|
||||
func LeftBodyHandler(ctx *fasthttp.RequestCtx) {
|
||||
requestLeftBodyMetric.Inc()
|
||||
|
||||
user := ctx.UserValue("user").(string)
|
||||
|
||||
opts := util.ParseQueryParams(ctx, config.Routes.LeftBody)
|
||||
@@ -460,6 +488,8 @@ func LeftBodyHandler(ctx *fasthttp.RequestCtx) {
|
||||
}
|
||||
|
||||
func RightBodyHandler(ctx *fasthttp.RequestCtx) {
|
||||
requestRightBodyMetric.Inc()
|
||||
|
||||
user := ctx.UserValue("user").(string)
|
||||
|
||||
opts := util.ParseQueryParams(ctx, config.Routes.RightBody)
|
||||
|
||||
@@ -13,6 +13,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
requestFaceMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "face_request_count",
|
||||
Help: "The amount of face requests",
|
||||
})
|
||||
renderFaceMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "face_render_count",
|
||||
Help: "The amount of face renders",
|
||||
@@ -20,6 +24,8 @@ var (
|
||||
)
|
||||
|
||||
func FaceHandler(ctx *fasthttp.RequestCtx) {
|
||||
requestFaceMetric.Inc()
|
||||
|
||||
user := ctx.UserValue("user").(string)
|
||||
|
||||
opts := util.ParseQueryParams(ctx, config.Routes.Face)
|
||||
|
||||
@@ -13,6 +13,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
requestHeadMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "head_request_count",
|
||||
Help: "The amount of head requests",
|
||||
})
|
||||
renderHeadMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "head_render_count",
|
||||
Help: "The amount of head renders",
|
||||
@@ -20,6 +24,8 @@ var (
|
||||
)
|
||||
|
||||
func HeadHandler(ctx *fasthttp.RequestCtx) {
|
||||
requestHeadMetric.Inc()
|
||||
|
||||
user := ctx.UserValue("user").(string)
|
||||
|
||||
opts := util.ParseQueryParams(ctx, config.Routes.Head)
|
||||
|
||||
@@ -15,10 +15,22 @@ import (
|
||||
"github.com/mineatar-io/api-server/src/conf"
|
||||
"github.com/mineatar-io/skin-render"
|
||||
"github.com/mineatar-io/yggdrasil"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"github.com/valyala/fasthttp"
|
||||
)
|
||||
|
||||
var Debug bool = os.Getenv("DEBUG") == "true"
|
||||
var (
|
||||
Debug bool = os.Getenv("DEBUG") == "true"
|
||||
yggdrasilUUIDLookupMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "yggdrasil_uuid_lookup_count",
|
||||
Help: "The amount of Yggdrasil UUID lookup requests",
|
||||
})
|
||||
yggdrasilTextureLookupMetric = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "yggdrasil_texture_lookup_count",
|
||||
Help: "The amount of Yggdrasil texture lookup requests",
|
||||
})
|
||||
)
|
||||
|
||||
type QueryParams struct {
|
||||
Scale int
|
||||
@@ -60,6 +72,8 @@ func LookupUUID(value string) (string, bool, error) {
|
||||
return "", false, err
|
||||
}
|
||||
|
||||
yggdrasilUUIDLookupMetric.Inc()
|
||||
|
||||
if profile == nil {
|
||||
if Debug {
|
||||
log.Printf("Fetched UUID from Mojang for '%s', did not exist\n", value)
|
||||
@@ -142,6 +156,8 @@ func GetPlayerSkin(uuid string) (*image.NRGBA, bool, error) {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
yggdrasilTextureLookupMetric.Inc()
|
||||
|
||||
if textures == nil {
|
||||
if Debug {
|
||||
log.Printf("Fetched textures for '%s' from Mojang, none exists, using default skin\n", uuid)
|
||||
|
||||
Reference in New Issue
Block a user