Created
April 28, 2020 18:34
-
-
Save edwardIshaq/6739887f28e7e4526f25931726db713e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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{}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wish that flags.OnUpdate vends an initial value here