Export profile requests metrics to statsd

This commit is contained in:
ErickSkrauch 2023-12-13 01:56:40 +01:00
parent dac4ed0ac6
commit 3cd12acc1b
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
3 changed files with 15 additions and 0 deletions

View File

@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] - xxxx-xx-xx
### Added
- New StatsD metrics:
- Counters:
- `ely.skinsystem.{hostname}.app.profiles.request`
### Changed
- Bumped Go version to 1.21.

View File

@ -133,6 +133,8 @@ func (s *StatsReporter) handleBeforeRequest(req *http.Request) {
key = "signed_textures.request"
} else if strings.HasPrefix(p, "/textures/") {
key = "textures.request"
} else if strings.HasPrefix(p, "/profile/") {
key = "profiles.request"
} else if m == http.MethodPost && p == "/api/skins" {
key = "api.skins.post.request"
} else if m == http.MethodDelete && strings.HasPrefix(p, "/api/skins/") {

View File

@ -99,6 +99,14 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"IncCounter", "signed_textures.request", int64(1)},
},
},
{
Events: [][]interface{}{
{"skinsystem:before_request", httptest.NewRequest("GET", "http://localhost/profile/username", nil)},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "profiles.request", int64(1)},
},
},
{
Events: [][]interface{}{
{"skinsystem:before_request", httptest.NewRequest("POST", "http://localhost/api/skins", nil)},