Merge pull request #9488 from thaJeztah/plugin_context_cancel

tracing/plugin: newTracer: ignore context.Canceled errors on Close()
This commit is contained in:
Derek McGowan 2023-12-18 19:41:21 +00:00 committed by GitHub
commit 8f6892a8c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@ package plugin
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"net/url" "net/url"
@ -66,7 +67,7 @@ func init() {
TraceSamplingRatio: 1.0, TraceSamplingRatio: 1.0,
}, },
InitFn: func(ic *plugin.InitContext) (interface{}, error) { InitFn: func(ic *plugin.InitContext) (interface{}, error) {
//get TracingProcessorPlugin which is a dependency // get TracingProcessorPlugin which is a dependency
plugins, err := ic.GetByType(plugins.TracingProcessorPlugin) plugins, err := ic.GetByType(plugins.TracingProcessorPlugin)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get tracing processors: %w", err) return nil, fmt.Errorf("failed to get tracing processors: %w", err)
@ -178,13 +179,12 @@ func newTracer(ctx context.Context, config *TraceConfig, procs []trace.SpanProce
return &closer{close: func() error { return &closer{close: func() error {
for _, p := range procs { for _, p := range procs {
if err := p.Shutdown(ctx); err != nil { if err := p.Shutdown(ctx); err != nil && !errors.Is(err, context.Canceled) {
return err return err
} }
} }
return nil return nil
}}, nil }}, nil
} }
// Returns a composite TestMap propagator // Returns a composite TestMap propagator