feat(telemetry)!: promote to v1.0.0 — named shutdown errors per provider, Go 1.26

Label each provider shutdown failure with its signal name (trace/metric/log).
Errors remain joined via errors.Join; individual causes still unwrappable.
Go directive bumped from 1.25 to 1.26. API committed as stable.
This commit is contained in:
2026-05-12 18:25:21 +00:00
parent 9304bed55b
commit 83ac0e3900
6 changed files with 92 additions and 7 deletions

View File

@@ -105,15 +105,30 @@ func New(ctx context.Context, cfg Config) (func(context.Context) error, error) {
global.SetLoggerProvider(lp)
shutdown := func(ctx context.Context) error {
return errors.Join(
tp.Shutdown(ctx),
mp.Shutdown(ctx),
lp.Shutdown(ctx),
)
var errs []error
if err := tp.Shutdown(ctx); err != nil {
errs = append(errs, &providerErr{"trace", err})
}
if err := mp.Shutdown(ctx); err != nil {
errs = append(errs, &providerErr{"metric", err})
}
if err := lp.Shutdown(ctx); err != nil {
errs = append(errs, &providerErr{"log", err})
}
return errors.Join(errs...)
}
return shutdown, nil
}
// providerErr labels a shutdown error with the provider name.
type providerErr struct {
provider string
err error
}
func (e *providerErr) Error() string { return "telemetry: " + e.provider + " provider shutdown: " + e.err.Error() }
func (e *providerErr) Unwrap() error { return e.err }
// newResource builds an OTel resource with service identity and environment attributes.
func newResource(cfg Config) *resource.Resource {
r, _ := resource.Merge(