From cada34149c9f275aa02e8f0d4da9d4a6ee3b53ef Mon Sep 17 00:00:00 2001 From: Ryan Martin Date: Wed, 9 Oct 2024 20:51:20 +0700 Subject: [PATCH] refactor: inline handleErr --- relay/nakama/telemetry.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/relay/nakama/telemetry.go b/relay/nakama/telemetry.go index e6dadaa3d..d600e0bf2 100644 --- a/relay/nakama/telemetry.go +++ b/relay/nakama/telemetry.go @@ -29,11 +29,6 @@ func initOtelSDK(ctx context.Context, logger runtime.Logger) (func(context.Conte return err } - var err error - handleErr := func(inErr error) { - err = errors.Join(inErr, shutdown(ctx)) - } - enableTrace := false globalTraceEnabled, err := strconv.ParseBool(os.Getenv(EnvTraceEnabled)) if err == nil { @@ -43,8 +38,7 @@ func initOtelSDK(ctx context.Context, logger runtime.Logger) (func(context.Conte if enableTrace { tracerProvider, err := newTracerProvider(ctx, logger) if err != nil { - handleErr(err) - return nil, err + return nil, errors.Join(err, shutdown(ctx)) } shutdownFuncs = append(shutdownFuncs, tracerProvider.Shutdown) otel.SetTracerProvider(tracerProvider) @@ -71,7 +65,7 @@ func newTracerProvider(ctx context.Context, logger runtime.Logger) (*trace.Trace var sampleRate float64 parsedSampleRate, err := strconv.ParseFloat(globalJaegerSampleRate, 64) if err != nil { - logger.Info("Invalid sample rate %s, defaulting to 0.6", parsedSampleRate) + logger.Info("Invalid sample rate %s, defaulting to 0.6", globalJaegerSampleRate) sampleRate = 0.6 } else { sampleRate = parsedSampleRate