Skip to content

Commit

Permalink
Export profile requests metrics to statsd
Browse files Browse the repository at this point in the history
  • Loading branch information
erickskrauch committed Dec 13, 2023
1 parent dac4ed0 commit 3cd12ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions eventsubscribers/stats_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/") {
Expand Down
8 changes: 8 additions & 0 deletions eventsubscribers/stats_reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down

0 comments on commit 3cd12ac

Please sign in to comment.