From 3a55524c861fba656567fb2ccb03da18bdc174c9 Mon Sep 17 00:00:00 2001 From: Howl Date: Sun, 2 Oct 2016 20:07:38 +0200 Subject: [PATCH] Add some more datadog crap --- app/method.go | 6 ++++++ app/peppy_method.go | 2 ++ 2 files changed, 8 insertions(+) diff --git a/app/method.go b/app/method.go index debb8fe..3885cab 100644 --- a/app/method.go +++ b/app/method.go @@ -23,6 +23,8 @@ func Method(f func(md common.MethodData) common.CodeMessager, privilegesNeeded . func initialCaretaker(c *gin.Context, f func(md common.MethodData) common.CodeMessager, privilegesNeeded ...int) { rateLimiter() + var doggoTags []string + data, err := ioutil.ReadAll(c.Request.Body) if err != nil { c.Error(err) @@ -51,6 +53,7 @@ func initialCaretaker(c *gin.Context, f func(md common.MethodData) common.CodeMe tokenReal, exists := GetTokenFull(token, db) if exists { md.User = tokenReal + doggoTags = append(doggoTags, "authorised") } } @@ -72,8 +75,11 @@ func initialCaretaker(c *gin.Context, f func(md common.MethodData) common.CodeMe // requests from hanayo should not be rate limited. if !(c.Request.Header.Get("H-Key") == cf.HanayoKey && c.Request.UserAgent() == "hanayo") { perUserRequestLimiter(md.ID(), c.ClientIP()) + doggoTags = append(doggoTags, "hanayo") } + doggo.Incr("requests.v1", doggoTags, 1) + missingPrivileges := 0 for _, privilege := range privilegesNeeded { if uint64(md.User.TokenPrivileges)&uint64(privilege) == 0 { diff --git a/app/peppy_method.go b/app/peppy_method.go index c70eac6..1a4b101 100644 --- a/app/peppy_method.go +++ b/app/peppy_method.go @@ -11,6 +11,8 @@ func PeppyMethod(a func(c *gin.Context, db *sqlx.DB)) gin.HandlerFunc { rateLimiter() perUserRequestLimiter(0, c.ClientIP()) + doggo.Incr("requests.peppy", nil, 1) + // I have no idea how, but I manged to accidentally string the first 4 // letters of the alphabet into a single function call. a(c, db)