Initialize subscribers on app bootstrapping

This commit is contained in:
ErickSkrauch 2020-04-04 19:14:12 +03:00
parent 0546b0519b
commit 2fbeb492f0
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
5 changed files with 119 additions and 102 deletions

View File

@ -6,6 +6,7 @@ import (
"time"
"github.com/getsentry/raven-go"
"github.com/mono83/slf"
"github.com/mono83/slf/rays"
"github.com/mono83/slf/recievers/sentry"
"github.com/mono83/slf/recievers/statsd"
@ -19,27 +20,12 @@ import (
"github.com/elyby/chrly/version"
)
func CreateLogger(statsdAddr string, sentryAddr string) (wd.Watchdog, error) {
func CreateLogger(sentryAddr string) (slf.Logger, error) {
wd.AddReceiver(writer.New(writer.Options{
Marker: false,
TimeFormat: "15:04:05.000",
}))
if statsdAddr != "" {
hostname, _ := os.Hostname()
statsdReceiver, err := statsd.NewReceiver(statsd.Config{
Address: statsdAddr,
Prefix: "ely.skinsystem." + hostname + ".app.",
FlushEvery: 1,
})
if err != nil {
return nil, err
}
wd.AddReceiver(statsdReceiver)
}
if sentryAddr != "" {
ravenClient, err := raven.New(sentryAddr)
if err != nil {
@ -66,6 +52,22 @@ func CreateLogger(statsdAddr string, sentryAddr string) (wd.Watchdog, error) {
return wd.New("", "").WithParams(rays.Host), nil
}
func CreateStatsReceiver(statsdAddr string) (slf.StatsReporter, error) {
hostname, _ := os.Hostname()
statsdReceiver, err := statsd.NewReceiver(statsd.Config{
Address: statsdAddr,
Prefix: "ely.skinsystem." + hostname + ".app.",
FlushEvery: 1,
})
if err != nil {
return nil, err
}
wd.AddReceiver(statsdReceiver)
return wd.New("", "").WithParams(rays.Host), nil
}
func init() {
viper.SetDefault("queue.loop_delay", 2*time.Second+500*time.Millisecond)
viper.SetDefault("queue.batch_size", 10)

View File

@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"log"
"os"
"github.com/mono83/slf/wd"
"github.com/spf13/cobra"
@ -10,6 +11,7 @@ import (
"github.com/elyby/chrly/bootstrap"
"github.com/elyby/chrly/db"
"github.com/elyby/chrly/eventsubscribers"
"github.com/elyby/chrly/http"
"github.com/elyby/chrly/mojangtextures"
)
@ -18,14 +20,27 @@ var serveCmd = &cobra.Command{
Use: "serve",
Short: "Starts HTTP handler for the skins system",
Run: func(cmd *cobra.Command, args []string) {
dispatcher := bootstrap.CreateEventDispatcher()
// TODO: this is a mess, need to organize this code somehow to make services initialization more compact
logger, err := bootstrap.CreateLogger(viper.GetString("statsd.addr"), viper.GetString("sentry.dsn"))
logger, err := bootstrap.CreateLogger(viper.GetString("sentry.dsn"))
if err != nil {
log.Fatal(fmt.Printf("Cannot initialize logger: %v", err))
log.Fatalf("Cannot initialize logger: %v", err)
}
logger.Info("Logger successfully initialized")
dispatcher := bootstrap.CreateEventDispatcher()
(&eventsubscribers.Logger{Logger: logger}).ConfigureWithDispatcher(dispatcher)
statsdAddr := viper.GetString("statsd.addr")
if statsdAddr != "" {
statsdReporter, err := bootstrap.CreateStatsReceiver(statsdAddr)
if err != nil {
logger.Emergency("Invalid statsd configuration :err", wd.ErrParam(err))
os.Exit(1)
}
(&eventsubscribers.StatsReporter{StatsReporter: statsdReporter}).ConfigureWithDispatcher(dispatcher)
}
storageFactory := db.StorageFactory{Config: viper.GetViper()}
@ -33,8 +48,8 @@ var serveCmd = &cobra.Command{
redisFactory := storageFactory.CreateFactory("redis")
skinsRepo, err := redisFactory.CreateSkinsRepository()
if err != nil {
logger.Emergency(fmt.Sprintf("Error on creating skins repo: %+v", err))
return
logger.Emergency("Error on creating skins repo: :err", wd.ErrParam(err))
os.Exit(1)
}
logger.Info("Skins repository successfully initialized")
@ -42,28 +57,28 @@ var serveCmd = &cobra.Command{
filesystemFactory := storageFactory.CreateFactory("filesystem")
capesRepo, err := filesystemFactory.CreateCapesRepository()
if err != nil {
logger.Emergency(fmt.Sprintf("Error on creating capes repo: %v", err))
return
logger.Emergency("Error on creating capes repo: :err", wd.ErrParam(err))
os.Exit(1)
}
logger.Info("Capes repository successfully initialized")
logger.Info("Preparing Mojang's textures queue")
mojangUuidsRepository, err := redisFactory.CreateMojangUuidsRepository()
if err != nil {
logger.Emergency(fmt.Sprintf("Error on creating mojang uuids repo: %v", err))
return
logger.Emergency("Error on creating mojang uuids repo: :err", wd.ErrParam(err))
os.Exit(1)
}
uuidsProvider, err := bootstrap.CreateMojangUUIDsProvider(dispatcher)
if err != nil {
logger.Emergency("Unable to parse remote url :err", wd.ErrParam(err))
return
os.Exit(1)
}
texturesStorage := mojangtextures.NewInMemoryTexturesStorage()
texturesStorage.Start()
mojangTexturesProvider := &mojangtextures.Provider{
Emitter: dispatcher,
Emitter: dispatcher,
UUIDsProvider: uuidsProvider,
TexturesProvider: &mojangtextures.MojangApiTexturesProvider{
Emitter: dispatcher,
@ -88,16 +103,16 @@ var serveCmd = &cobra.Command{
finishChan := make(chan bool)
go func() {
logger.Info(fmt.Sprintf("Starting the app, HTTP on: %s", address))
logger.Info("Starting the app, HTTP on: :addr", wd.StringParam("addr", address))
if err := http.Serve(address, handler); err != nil {
logger.Error(fmt.Sprintf("Error in main(): %v", err))
logger.Emergency("Error in main(): :err", wd.ErrParam(err))
finishChan <- true
}
}()
go func() {
s := waitForExitSignal()
logger.Info(fmt.Sprintf("Got signal: %v, exiting.", s))
logger.Info("Got signal: :signal, exiting", wd.StringParam("signal", s.String()))
finishChan <- true
}()

View File

@ -3,12 +3,14 @@ package cmd
import (
"fmt"
"log"
"os"
"github.com/mono83/slf/wd"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/elyby/chrly/bootstrap"
"github.com/elyby/chrly/eventsubscribers"
"github.com/elyby/chrly/http"
)
@ -16,18 +18,32 @@ var workerCmd = &cobra.Command{
Use: "worker",
Short: "Starts HTTP handler for the Mojang usernames to UUIDs worker",
Run: func(cmd *cobra.Command, args []string) {
logger, err := bootstrap.CreateLogger(viper.GetString("statsd.addr"), viper.GetString("sentry.dsn"))
dispatcher := bootstrap.CreateEventDispatcher()
// TODO: need to find a way to unify this initialization with the serve command
logger, err := bootstrap.CreateLogger(viper.GetString("sentry.dsn"))
if err != nil {
log.Fatal(fmt.Printf("Cannot initialize logger: %v", err))
log.Fatalf("Cannot initialize logger: %v", err)
}
logger.Info("Logger successfully initialized")
dispatcher := bootstrap.CreateEventDispatcher()
(&eventsubscribers.Logger{Logger: logger}).ConfigureWithDispatcher(dispatcher)
statsdAddr := viper.GetString("statsd.addr")
if statsdAddr != "" {
statsdReporter, err := bootstrap.CreateStatsReceiver(statsdAddr)
if err != nil {
logger.Emergency("Invalid statsd configuration :err", wd.ErrParam(err))
os.Exit(1)
}
(&eventsubscribers.StatsReporter{StatsReporter: statsdReporter}).ConfigureWithDispatcher(dispatcher)
}
uuidsProvider, err := bootstrap.CreateMojangUUIDsProvider(dispatcher)
if err != nil {
logger.Emergency("Unable to parse remote url :err", wd.ErrParam(err))
return
os.Exit(1)
}
address := fmt.Sprintf("%s:%d", viper.GetString("server.host"), viper.GetInt("server.port"))
@ -38,16 +54,16 @@ var workerCmd = &cobra.Command{
finishChan := make(chan bool)
go func() {
logger.Info(fmt.Sprintf("Starting the worker, HTTP on: %s", address))
logger.Info("Starting the worker, HTTP on: :addr", wd.StringParam("addr", address))
if err := http.Serve(address, handler); err != nil {
logger.Error(fmt.Sprintf("Error in main(): %v", err))
logger.Error("Error in main(): :err", wd.ErrParam(err))
finishChan <- true
}
}()
go func() {
s := waitForExitSignal()
logger.Info(fmt.Sprintf("Got signal: %v, exiting.", s))
logger.Info("Got signal: :code, exiting.", wd.StringParam("code", s.String()))
finishChan <- true
}()

View File

@ -40,9 +40,9 @@ func (s *StatsReporter) ConfigureWithDispatcher(d Subscriber) {
}
if uuid == "" {
s.incCounter("mojang_textures:usernames:cache_hit_nil")
s.IncCounter("mojang_textures:usernames:cache_hit_nil", 1)
} else {
s.incCounter("mojang_textures:usernames:cache_hit")
s.IncCounter("mojang_textures:usernames:cache_hit", 1)
}
})
d.Subscribe("mojang_textures:textures:after_cache", func(uuid string, textures *mojang.SignedTexturesResponse, err error) {
@ -51,7 +51,7 @@ func (s *StatsReporter) ConfigureWithDispatcher(d Subscriber) {
}
if textures != nil {
s.incCounter("mojang_textures.textures.cache_hit")
s.IncCounter("mojang_textures.textures.cache_hit", 1)
}
})
d.Subscribe("mojang_textures:already_processing", s.incCounterHandler("mojang_textures.already_scheduled"))
@ -61,9 +61,9 @@ func (s *StatsReporter) ConfigureWithDispatcher(d Subscriber) {
}
if profile == nil {
s.incCounter("mojang_textures.usernames.uuid_miss")
s.IncCounter("mojang_textures.usernames.uuid_miss", 1)
} else {
s.incCounter("mojang_textures.usernames.uuid_hit")
s.IncCounter("mojang_textures.usernames.uuid_hit", 1)
}
})
d.Subscribe("mojang_textures:textures:before_call", s.incCounterHandler("mojang_textures.textures.request"))
@ -73,9 +73,9 @@ func (s *StatsReporter) ConfigureWithDispatcher(d Subscriber) {
}
if textures == nil {
s.incCounter("mojang_textures.usernames.textures_miss")
s.IncCounter("mojang_textures.usernames.textures_miss", 1)
} else {
s.incCounter("mojang_textures.usernames.textures_hit")
s.IncCounter("mojang_textures.usernames.textures_hit", 1)
}
})
d.Subscribe("mojang_textures:before_result", func(username string, uuid string) {
@ -94,8 +94,8 @@ func (s *StatsReporter) ConfigureWithDispatcher(d Subscriber) {
// Mojang UUIDs batch provider metrics
d.Subscribe("mojang_textures:batch_uuids_provider:queued", s.incCounterHandler("mojang_textures.usernames.queued"))
d.Subscribe("mojang_textures:batch_uuids_provider:round", func(usernames []string, queueSize int) {
s.updateGauge("mojang_textures.usernames.iteration_size", int64(len(usernames)))
s.updateGauge("mojang_textures.usernames.queue_size", int64(queueSize))
s.UpdateGauge("mojang_textures.usernames.iteration_size", int64(len(usernames)))
s.UpdateGauge("mojang_textures.usernames.queue_size", int64(queueSize))
})
d.Subscribe("mojang_textures:batch_uuids_provider:before_round", func() {
s.startTimeRecording("batch_uuids_provider_round_time")
@ -129,7 +129,7 @@ func (s *StatsReporter) handleBeforeRequest(req *http.Request) {
return
}
s.incCounter(key)
s.IncCounter(key, 1)
}
func (s *StatsReporter) handleAfterRequest(req *http.Request, code int) {
@ -148,12 +148,12 @@ func (s *StatsReporter) handleAfterRequest(req *http.Request, code int) {
return
}
s.incCounter(key)
s.IncCounter(key, 1)
}
func (s *StatsReporter) incCounterHandler(name string) func(...interface{}) {
return func(...interface{}) {
s.incCounter(name)
s.IncCounter(name, 1)
}
}
@ -173,21 +173,5 @@ func (s *StatsReporter) finalizeTimeRecording(timeKey string, statName string) {
delete(s.timersMap, timeKey)
s.recordTimer(statName, time.Since(startedAt))
}
func (s *StatsReporter) incCounter(name string) {
s.IncCounter(s.key(name), 1)
}
func (s *StatsReporter) updateGauge(name string, value int64) {
s.UpdateGauge(s.key(name), value)
}
func (s *StatsReporter) recordTimer(name string, duration time.Duration) {
s.RecordTimer(s.key(name), duration)
}
func (s *StatsReporter) key(name string) string {
return strings.Join([]string{s.Prefix, name}, ".")
s.RecordTimer(statName, time.Since(startedAt))
}

View File

@ -55,7 +55,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:before_request", httptest.NewRequest("GET", "http://localhost/skins/username", nil)},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.skins.request", int64(1)},
{"IncCounter", "skins.request", int64(1)},
},
},
{
@ -63,7 +63,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:before_request", httptest.NewRequest("GET", "http://localhost/skins?name=username", nil)},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.skins.get_request", int64(1)},
{"IncCounter", "skins.get_request", int64(1)},
},
},
{
@ -71,7 +71,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:before_request", httptest.NewRequest("GET", "http://localhost/cloaks/username", nil)},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.capes.request", int64(1)},
{"IncCounter", "capes.request", int64(1)},
},
},
{
@ -79,7 +79,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:before_request", httptest.NewRequest("GET", "http://localhost/cloaks?name=username", nil)},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.capes.get_request", int64(1)},
{"IncCounter", "capes.get_request", int64(1)},
},
},
{
@ -87,7 +87,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:before_request", httptest.NewRequest("GET", "http://localhost/textures/username", nil)},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.textures.request", int64(1)},
{"IncCounter", "textures.request", int64(1)},
},
},
{
@ -95,7 +95,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:before_request", httptest.NewRequest("GET", "http://localhost/textures/signed/username", nil)},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.signed_textures.request", int64(1)},
{"IncCounter", "signed_textures.request", int64(1)},
},
},
{
@ -103,7 +103,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:before_request", httptest.NewRequest("POST", "http://localhost/api/skins", nil)},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.api.skins.post.request", int64(1)},
{"IncCounter", "api.skins.post.request", int64(1)},
},
},
{
@ -111,7 +111,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:before_request", httptest.NewRequest("DELETE", "http://localhost/api/skins/username", nil)},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.api.skins.delete.request", int64(1)},
{"IncCounter", "api.skins.delete.request", int64(1)},
},
},
{
@ -119,7 +119,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:before_request", httptest.NewRequest("DELETE", "http://localhost/api/skins/id:1", nil)},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.api.skins.delete.request", int64(1)},
{"IncCounter", "api.skins.delete.request", int64(1)},
},
},
{
@ -134,7 +134,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:after_request", httptest.NewRequest("POST", "http://localhost/api/skins", nil), 201},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.api.skins.post.success", int64(1)},
{"IncCounter", "api.skins.post.success", int64(1)},
},
},
{
@ -142,7 +142,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:after_request", httptest.NewRequest("POST", "http://localhost/api/skins", nil), 400},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.api.skins.post.validation_failed", int64(1)},
{"IncCounter", "api.skins.post.validation_failed", int64(1)},
},
},
{
@ -150,7 +150,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:after_request", httptest.NewRequest("DELETE", "http://localhost/api/skins/username", nil), 204},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.api.skins.delete.success", int64(1)},
{"IncCounter", "api.skins.delete.success", int64(1)},
},
},
{
@ -158,7 +158,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:after_request", httptest.NewRequest("DELETE", "http://localhost/api/skins/username", nil), 404},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.api.skins.delete.not_found", int64(1)},
{"IncCounter", "api.skins.delete.not_found", int64(1)},
},
},
{
@ -166,7 +166,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:after_request", httptest.NewRequest("DELETE", "http://localhost/api/skins/id:1", nil), 204},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.api.skins.delete.success", int64(1)},
{"IncCounter", "api.skins.delete.success", int64(1)},
},
},
{
@ -174,7 +174,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"skinsystem:after_request", httptest.NewRequest("DELETE", "http://localhost/api/skins/id:1", nil), 404},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.api.skins.delete.not_found", int64(1)},
{"IncCounter", "api.skins.delete.not_found", int64(1)},
},
},
{
@ -189,8 +189,8 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"authenticator:success"},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.authentication.challenge", int64(1)},
{"IncCounter", "mock_prefix.authentication.success", int64(1)},
{"IncCounter", "authentication.challenge", int64(1)},
{"IncCounter", "authentication.success", int64(1)},
},
},
{
@ -198,8 +198,8 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"authentication:error", errors.New("error")},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.authentication.challenge", int64(1)},
{"IncCounter", "mock_prefix.authentication.failed", int64(1)},
{"IncCounter", "authentication.challenge", int64(1)},
{"IncCounter", "authentication.failed", int64(1)},
},
},
// Mojang signed textures provider
@ -208,7 +208,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:call", "username"},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures.request", int64(1)},
{"IncCounter", "mojang_textures.request", int64(1)},
},
},
{
@ -222,7 +222,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:usernames:after_cache", "username", "", nil},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures:usernames:cache_hit_nil", int64(1)},
{"IncCounter", "mojang_textures:usernames:cache_hit_nil", int64(1)},
},
},
{
@ -230,7 +230,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:usernames:after_cache", "username", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", nil},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures:usernames:cache_hit", int64(1)},
{"IncCounter", "mojang_textures:usernames:cache_hit", int64(1)},
},
},
{
@ -250,7 +250,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:textures:after_cache", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", &mojang.SignedTexturesResponse{}, nil},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures.textures.cache_hit", int64(1)},
{"IncCounter", "mojang_textures.textures.cache_hit", int64(1)},
},
},
{
@ -258,7 +258,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:already_processing", "username"},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures.already_scheduled", int64(1)},
{"IncCounter", "mojang_textures.already_scheduled", int64(1)},
},
},
{
@ -272,7 +272,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:usernames:after_call", "username", nil, nil},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures.usernames.uuid_miss", int64(1)},
{"IncCounter", "mojang_textures.usernames.uuid_miss", int64(1)},
},
},
{
@ -280,7 +280,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:usernames:after_call", "username", &mojang.ProfileInfo{}, nil},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures.usernames.uuid_hit", int64(1)},
{"IncCounter", "mojang_textures.usernames.uuid_hit", int64(1)},
},
},
{
@ -294,7 +294,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:textures:after_call", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", nil, nil},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures.usernames.textures_miss", int64(1)},
{"IncCounter", "mojang_textures.usernames.textures_miss", int64(1)},
},
},
{
@ -302,7 +302,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:textures:after_call", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", &mojang.SignedTexturesResponse{}, nil},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures.usernames.textures_hit", int64(1)},
{"IncCounter", "mojang_textures.usernames.textures_hit", int64(1)},
},
},
{
@ -311,7 +311,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:after_result", "username", &mojang.SignedTexturesResponse{}, nil},
},
ExpectedCalls: [][]interface{}{
{"RecordTimer", "mock_prefix.mojang_textures.result_time", mock.AnythingOfType("time.Duration")},
{"RecordTimer", "mojang_textures.result_time", mock.AnythingOfType("time.Duration")},
},
},
{
@ -320,9 +320,9 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:textures:after_call", "аааааааааааааааааааааааааааааааа", &mojang.SignedTexturesResponse{}, nil},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures.textures.request", int64(1)},
{"IncCounter", "mock_prefix.mojang_textures.usernames.textures_hit", int64(1)},
{"RecordTimer", "mock_prefix.mojang_textures.textures.request_time", mock.AnythingOfType("time.Duration")},
{"IncCounter", "mojang_textures.textures.request", int64(1)},
{"IncCounter", "mojang_textures.usernames.textures_hit", int64(1)},
{"RecordTimer", "mojang_textures.textures.request_time", mock.AnythingOfType("time.Duration")},
},
},
// Batch UUIDs provider
@ -331,7 +331,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:batch_uuids_provider:queued", "username"},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures.usernames.queued", int64(1)},
{"IncCounter", "mojang_textures.usernames.queued", int64(1)},
},
},
{
@ -339,8 +339,8 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:batch_uuids_provider:round", []string{"username1", "username2"}, 5},
},
ExpectedCalls: [][]interface{}{
{"UpdateGauge", "mock_prefix.mojang_textures.usernames.iteration_size", int64(2)},
{"UpdateGauge", "mock_prefix.mojang_textures.usernames.queue_size", int64(5)},
{"UpdateGauge", "mojang_textures.usernames.iteration_size", int64(2)},
{"UpdateGauge", "mojang_textures.usernames.queue_size", int64(5)},
},
},
{
@ -349,7 +349,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{"mojang_textures:batch_uuids_provider:after_round"},
},
ExpectedCalls: [][]interface{}{
{"RecordTimer", "mock_prefix.mojang_textures.usernames.round_time", mock.AnythingOfType("time.Duration")},
{"RecordTimer", "mojang_textures.usernames.round_time", mock.AnythingOfType("time.Duration")},
},
},
}