Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional error handling on OpenTel callback #6545

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions runtime/pkg/observability/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,27 @@ func Start(ctx context.Context, logger *zap.Logger, opts *Options) (ShutdownFunc

// Create callback to shut down globals
shutdown := func(ctx context.Context) error {
var err1, err2 error
var errs []error
if meterProvider != nil {
err1 = meterProvider.Shutdown(ctx)
if err := meterProvider.Shutdown(ctx); err != nil {
errs = append(errs, err)
}
}
if tracerProvider != nil {
err2 = tracerProvider.Shutdown(ctx)
if err := tracerProvider.ForceFlush(ctx); err != nil {
errs = append(errs, fmt.Errorf("failed to flush spans: %w", err))
}
if err := tracerProvider.Shutdown(ctx); err != nil {
errs = append(errs, err)
}
}
if err1 != nil {
return err1
if len(errs) == 1 {
return fmt.Errorf("error while shutting down: %w", errs[0])
}
return err2
if len(errs) > 1 {
return fmt.Errorf("multiple errors while shutting down: %v", errs)
}
return nil
}
return shutdown, nil
}
Loading