Skip to content

Commit

Permalink
ensure the sdk is shutdown on error
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten committed Nov 6, 2024
1 parent 408f904 commit b16c14d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,22 @@ func New(ctx context.Context, set Settings, cfg Config) (*Service, error) {

logger, lp, err := telFactory.CreateLogger(ctx, telset, &cfg.Telemetry)
if err != nil {
err = multierr.Append(err, sdk.Shutdown(ctx))
return nil, fmt.Errorf("failed to create logger: %w", err)
}
srv.loggerProvider = lp

tracerProvider, err := telFactory.CreateTracerProvider(ctx, telset, &cfg.Telemetry)
if err != nil {
err = multierr.Append(err, sdk.Shutdown(ctx))
return nil, fmt.Errorf("failed to create tracer provider: %w", err)
}

logger.Info("Setting up own telemetry...")

mp, err := telFactory.CreateMeterProvider(ctx, telset, &cfg.Telemetry)
if err != nil {
err = multierr.Append(err, sdk.Shutdown(ctx))
return nil, fmt.Errorf("failed to create meter provider: %w", err)
}

Expand Down

0 comments on commit b16c14d

Please sign in to comment.