Skip to content

TracerProvider ForceFlush() Error Fix#7856

Merged
pellared merged 17 commits intoopen-telemetry:mainfrom
sawamurataxman:trace-force-flush-errors
Mar 5, 2026
Merged

TracerProvider ForceFlush() Error Fix#7856
pellared merged 17 commits intoopen-telemetry:mainfrom
sawamurataxman:trace-force-flush-errors

Conversation

@sawamurataxman
Copy link
Copy Markdown
Contributor

Previously upon a SpanProcessor's ForceFlush returning an error, it would return that error and not attempt to flush subsequent SpanProcessors. Now when an error is encountered, it will Join the new error with the existing errors and continue iterating through the SpanProcessors and return the consolidated error at the end of iteration. This is in line with the workflow found in LoggerProvider's ForceFlush.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Jan 31, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: pellared / name: Robert Pająk (86311aa)

@sawamurataxman sawamurataxman marked this pull request as ready for review January 31, 2026 17:24
Copy link
Copy Markdown
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Can you add a test?

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.6%. Comparing base (78f9904) to head (86311aa).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #7856     +/-   ##
=======================================
- Coverage   81.6%   81.6%   -0.1%     
=======================================
  Files        304     304             
  Lines      23389   23389             
=======================================
- Hits       19096   19095      -1     
- Misses      3906    3907      +1     
  Partials     387     387             
Files with missing lines Coverage Δ
sdk/trace/provider.go 86.7% <100.0%> (+0.9%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sawamurataxman
Copy link
Copy Markdown
Contributor Author

Sorry for pinging while checks are failing - working on it.

@sawamurataxman
Copy link
Copy Markdown
Contributor Author

Anything else I can/should do for this to get it merged?

Removed extra line breaks in CHANGELOG for clarity.
Co-authored-by: Robert Pająk <pellared@hotmail.com>
@pellared pellared added this to the v1.42.0 milestone Mar 4, 2026
@pellared pellared merged commit fdd1320 into open-telemetry:main Mar 5, 2026
34 checks passed
pellared added a commit that referenced this pull request Mar 6, 2026
### Added

- Add `go.opentelemetry.io/otel/semconv/v1.40.0` package.
The package contains semantic conventions from the `v1.40.0` version of
the OpenTelemetry Semantic Conventions.
See the [migration documentation](./semconv/v1.40.0/MIGRATION.md) for
information on how to upgrade from
`go.opentelemetry.io/otel/semconv/v1.39.0`. (#7985)
- Add `Err` and `SetErr` on `Record` in `go.opentelemetry.io/otel/log`
to attach an error and set record exception attributes in
`go.opentelemetry.io/otel/log/sdk`. (#7924)

### Changed

- `TracerProvider.ForceFlush` in `go.opentelemetry.io/otel/sdk/trace`
joins errors together and continues iteration through SpanProcessors as
opposed to returning the first encountered error without attempting
exports on subsequent SpanProcessors. (#7856)

### Fixed

- Fix missing `request.GetBody` in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` to
correctly handle HTTP2 GOAWAY frame. (#7931)
- Fix semconv v1.39.0 generated metric helpers skipping required
attributes when extra attributes were empty. (#7964)
- Preserve W3C TraceFlags bitmask (including the random Trace ID flag)
during trace context extraction and injection in
`go.opentelemetry.io/otel/propagation`. (#7834)

### Removed

- Drop support for [Go 1.24]. (#7984)
if err := sps.sp.ForceFlush(ctx); err != nil {
return err
}
err = errors.Join(err, sps.sp.ForceFlush(ctx))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a singly-linked list of errors.joinErrors, each of them but the first containing only two errors, one of which is the errors.joinError from the previous failure in calling ForceFlush.

What I expect that you intended to create here was a flat sequence of errors. Sketching:

errs := make([]error, 0, len(spss))
for _, sps := range spss {
  // ...
  if err := sps.sp.ForceFlush(ctx); err != nil {
    errs = append(errs, err)
  }
}
return errors.Join(errs...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants