Skip to content

Commit

Permalink
[bug] [hotrod] Delay env var mapping until logger is initialized (jae…
Browse files Browse the repository at this point in the history
…gertracing#5760)

## Which problem is this PR solving?
- Resolves jaegertracing#5759 

## Description of the changes
- Invoke mapping function (which takes logger) after the logger is
initialized
- It is safe to do because none of the env vars control the logic for
logger initialization

## How was this change tested?
- `$ JAEGER_AGENT_PORT=xyz go run ./examples/hotrod  all`
- Before the change this command would cause a panic

Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro authored and FlamingSaint committed Jul 20, 2024
1 parent 9988820 commit 8b8c4ed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/hotrod/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ func init() {

// onInitialize is called before the command is executed.
func onInitialize() {
jaegerclientenv2otel.MapJaegerToOtelEnvVars(logger)

zapOptions := []zap.Option{
zap.AddStacktrace(zapcore.FatalLevel),
zap.AddCallerSkip(1),
Expand All @@ -68,6 +66,9 @@ func onInitialize() {
)
}
logger, _ = zap.NewDevelopment(zapOptions...)

jaegerclientenv2otel.MapJaegerToOtelEnvVars(logger)

metricsFactory = prometheus.New().Namespace(metrics.NSOptions{Name: "hotrod", Tags: nil})

if config.MySQLGetDelay != fixDBConnDelay {
Expand Down

0 comments on commit 8b8c4ed

Please sign in to comment.