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

Fix flaky test TestSimpleSpanProcessorShutdownHonorsContextCancel #2290

Merged
merged 9 commits into from Oct 19, 2021
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -23,6 +23,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Adds `otlptracegrpc.WithGRPCConn` and `otlpmetricgrpc.WithGRPCConn` for reusing existing gRPC connection. (#2002)
- Added a new `schema` module to help parse Schema Files in OTEP 0152 format. (#2267)

### Fixed

- The simple span processor shutdown method returns any context error if there is one and the exporter successfully shuts down. (#2290, #2289)
MrAlias marked this conversation as resolved.
Show resolved Hide resolved

## [1.0.1] - 2021-10-01

### Fixed
Expand Down
10 changes: 10 additions & 0 deletions sdk/trace/simple_span_processor.go
Expand Up @@ -90,6 +90,16 @@ func (ssp *simpleSpanProcessor) Shutdown(ctx context.Context) error {

select {
case err = <-done:
// It is possible for the exporter to have immediately shut down and
// the context to already be done. In that case this select statement
// will randomly choose a case. This could result in a different
// response for similar scenarios. Instead, double check if the
// context is done here and return that error if the exporter shut
// down did not return one.
if err == nil {
// If ctx is not done yet, ctx.Err returns nil.
err = ctx.Err()
}
MrAlias marked this conversation as resolved.
Show resolved Hide resolved
case <-ctx.Done():
err = ctx.Err()
}
Expand Down