Add some more datadog crap

This commit is contained in:
Howl 2016-10-02 20:07:38 +02:00
parent da0021a9b3
commit 3a55524c86
2 changed files with 8 additions and 0 deletions

View File

@ -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) { func initialCaretaker(c *gin.Context, f func(md common.MethodData) common.CodeMessager, privilegesNeeded ...int) {
rateLimiter() rateLimiter()
var doggoTags []string
data, err := ioutil.ReadAll(c.Request.Body) data, err := ioutil.ReadAll(c.Request.Body)
if err != nil { if err != nil {
c.Error(err) c.Error(err)
@ -51,6 +53,7 @@ func initialCaretaker(c *gin.Context, f func(md common.MethodData) common.CodeMe
tokenReal, exists := GetTokenFull(token, db) tokenReal, exists := GetTokenFull(token, db)
if exists { if exists {
md.User = tokenReal 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. // requests from hanayo should not be rate limited.
if !(c.Request.Header.Get("H-Key") == cf.HanayoKey && c.Request.UserAgent() == "hanayo") { if !(c.Request.Header.Get("H-Key") == cf.HanayoKey && c.Request.UserAgent() == "hanayo") {
perUserRequestLimiter(md.ID(), c.ClientIP()) perUserRequestLimiter(md.ID(), c.ClientIP())
doggoTags = append(doggoTags, "hanayo")
} }
doggo.Incr("requests.v1", doggoTags, 1)
missingPrivileges := 0 missingPrivileges := 0
for _, privilege := range privilegesNeeded { for _, privilege := range privilegesNeeded {
if uint64(md.User.TokenPrivileges)&uint64(privilege) == 0 { if uint64(md.User.TokenPrivileges)&uint64(privilege) == 0 {

View File

@ -11,6 +11,8 @@ func PeppyMethod(a func(c *gin.Context, db *sqlx.DB)) gin.HandlerFunc {
rateLimiter() rateLimiter()
perUserRequestLimiter(0, c.ClientIP()) perUserRequestLimiter(0, c.ClientIP())
doggo.Incr("requests.peppy", nil, 1)
// I have no idea how, but I manged to accidentally string the first 4 // I have no idea how, but I manged to accidentally string the first 4
// letters of the alphabet into a single function call. // letters of the alphabet into a single function call.
a(c, db) a(c, db)