Skip to content

Instantly share code, notes, and snippets.

@edwardIshaq
Created April 28, 2020 18:34
Show Gist options
  • Save edwardIshaq/6739887f28e7e4526f25931726db713e to your computer and use it in GitHub Desktop.
Save edwardIshaq/6739887f28e7e4526f25931726db713e to your computer and use it in GitHub Desktop.
//Opentracing setup
var jaegerCloser io.Closer
var zErr error
var closeJaegerIfNeeded = func() {
if jaegerCloser != nil {
if err := jaegerCloser.Close(); err != nil {
logging.Error("Failed to close tracing with error: %s", err.Error())
}
jaegerCloser = nil
}
}
defer closeJaegerIfNeeded()
if ff.Opentracing.IsEnabled() {
if jaegerCloser, zErr = setupOpenTracing(mode); zErr != nil {
logging.Errorf("openTracing setup failed with error: %s", zErr.Error())
}
}
flags.OnUpdate(func(ff *flags.FlannelFlags) {
if ff.Opentracing.IsEnabled() {
logging.Info("Opentracing was enabled")
if jaegerCloser, zErr = setupOpenTracing(mode); zErr != nil {
logging.Errorf("openTracing setup failed with error: %s", zErr.Error())
}
} else {
logging.Info("Opentracing was disabled")
closeJaegerIfNeeded()
opentracing.SetGlobalTracer(opentracing.NoopTracer{})
}
})
@edwardIshaq
Copy link
Author

I wish that flags.OnUpdate vends an initial value here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment