Skip to content

Commit

Permalink
add server/metrics tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krrrr38 committed Jan 15, 2023
1 parent 615fe16 commit eac7553
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions server/metrics/counter_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package metrics

import (
"testing"

"github.com/uber-go/tally"
)

func TestInitCounter(t *testing.T) {
scope := tally.NewTestScope("test", nil)

InitCounter(scope, "counter")

counter, ok := scope.Snapshot().Counters()["test.counter+"]
if !ok {
t.Errorf("Counter not found")
}
if counter.Value() != 0 {
t.Errorf("Counter is not initialized")
}
}
4 changes: 2 additions & 2 deletions server/metrics/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newReporter(cfg valid.Metrics, logger logging.SimpleLogging) (tally.BaseSta

// return statsd metrics if configured
if cfg.Statsd != nil {
return newStatsReporter(cfg, logger)
return newStatsReporter(cfg)
}

// return prometheus metrics if configured
Expand All @@ -58,7 +58,7 @@ func newReporter(cfg valid.Metrics, logger logging.SimpleLogging) (tally.BaseSta

}

func newStatsReporter(cfg valid.Metrics, logger logging.SimpleLogging) (tally.StatsReporter, error) {
func newStatsReporter(cfg valid.Metrics) (tally.StatsReporter, error) {

statsdCfg := cfg.Statsd

Expand Down

0 comments on commit eac7553

Please sign in to comment.