diff --git a/api/app.go b/api/app.go index abe84db..934bc61 100644 --- a/api/app.go +++ b/api/app.go @@ -23,10 +23,10 @@ import ( "github.com/getsentry/raven-go" "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/opentracing/opentracing-go" "github.com/rcrowley/go-metrics" uuid "github.com/satori/go.uuid" "github.com/spf13/viper" - "github.com/topfreegames/extensions/jaeger" "github.com/topfreegames/podium/leaderboard/v2/database" "github.com/topfreegames/podium/leaderboard/v2/service" lservice "github.com/topfreegames/podium/leaderboard/v2/service" @@ -40,6 +40,7 @@ import ( newrelic "github.com/newrelic/go-agent" extnethttpmiddleware "github.com/topfreegames/extensions/middleware" api "github.com/topfreegames/podium/proto/podium/api/v1" + jaegercfg "github.com/uber/jaeger-client-go/config" ) // JSON type @@ -219,16 +220,24 @@ func (app *App) configureJaeger() { zap.String("operation", "configureJaeger"), ) - opts := jaeger.Options{ - Disabled: app.Config.GetBool("jaeger.disabled"), - Probability: app.Config.GetFloat64("jaeger.samplingProbability"), - ServiceName: "podium", + cfg, err := jaegercfg.FromEnv() + if err != nil { + l.Error("Could not parse Jaeger env vars", zap.Error(err)) + return + } + + if cfg.ServiceName == "" { + cfg.ServiceName = "podium" } - _, err := jaeger.Configure(opts) + tracer, _, err := cfg.NewTracer() if err != nil { - l.Error("Failed to initialize Jaeger.") + l.Error("Could not initialize jaeger tracer", zap.Error(err)) + return } + + opentracing.SetGlobalTracer(tracer) + l.Info(fmt.Sprintf("Tracer configured for %s", cfg.Reporter.LocalAgentHostPort)) } func (app *App) setConfigurationDefaults() { @@ -241,8 +250,6 @@ func (app *App) setConfigurationDefaults() { app.Config.SetDefault("redis.password", "") app.Config.SetDefault("redis.db", 0) app.Config.SetDefault("redis.connectionTimeout", 200) - app.Config.SetDefault("jaeger.disabled", true) - app.Config.SetDefault("jaeger.samplingProbability", 0.001) app.Config.SetDefault("redis.cluster.enabled", false) } diff --git a/go.mod b/go.mod index b5886b1..4247609 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/newrelic/go-agent v1.11.0 github.com/onsi/ginkgo v1.16.2 github.com/onsi/gomega v1.11.0 - github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/opentracing/opentracing-go v1.2.0 github.com/rcrowley/go-metrics v0.0.0-20180125231941-8732c616f529 github.com/satori/go.uuid v1.2.0 github.com/spf13/cobra v0.0.6 @@ -36,7 +36,7 @@ require ( github.com/spf13/viper v1.7.1 github.com/topfreegames/extensions v8.0.2+incompatible github.com/topfreegames/podium/leaderboard/v2 v2.0.0 - github.com/uber/jaeger-client-go v2.25.0+incompatible // indirect + github.com/uber/jaeger-client-go v2.29.1+incompatible github.com/uber/jaeger-lib v2.4.1+incompatible // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v0.0.0-20161005094451-07f692d02d61 diff --git a/go.sum b/go.sum index 7aaca67..4a51748 100644 --- a/go.sum +++ b/go.sum @@ -303,6 +303,8 @@ github.com/topfreegames/extensions v8.0.2+incompatible h1:4LMv5SBpep8WkUVGmgpGg0 github.com/topfreegames/extensions v8.0.2+incompatible/go.mod h1:VbIAks7aNbkANieZyVShAV3FSxEbV6useS4r3neXVzc= github.com/uber/jaeger-client-go v2.25.0+incompatible h1:IxcNZ7WRY1Y3G4poYlx24szfsn/3LvK9QHCq9oQw8+U= github.com/uber/jaeger-client-go v2.25.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= +github.com/uber/jaeger-client-go v2.29.1+incompatible h1:R9ec3zO3sGpzs0abd43Y+fBZRJ9uiH6lXyR/+u6brW4= +github.com/uber/jaeger-client-go v2.29.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=