Skip to content

Commit

Permalink
[bug] [hotrod] Delay env var mapping until logger is initialized (#5760)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Resolves #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 <github@ysh.us>
  • Loading branch information
yurishkuro committed Jul 17, 2024
1 parent 0e7f3f4 commit c68136e
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 c68136e

Please sign in to comment.