Skip to content

Commit

Permalink
refactor: inline handleErr
Browse files Browse the repository at this point in the history
  • Loading branch information
rmrt1n committed Oct 9, 2024
1 parent c07ed20 commit cada341
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions relay/nakama/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit cada341

Please sign in to comment.