Skip to content

Commit

Permalink
Update jeager (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur29 committed Jul 26, 2021
1 parent 1b31207 commit 78effb7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
25 changes: 16 additions & 9 deletions api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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
github.com/spf13/pflag v1.0.5 // indirect
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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 78effb7

Please sign in to comment.