Skip to content

fix(sdk-trace, sdk-logs): invoke all lifecycle processors - #6980

Open
teamleaderleo wants to merge 1 commit into
open-telemetry:mainfrom
teamleaderleo:upstream/unit-11-lifecycle-fanout-v2
Open

fix(sdk-trace, sdk-logs): invoke all lifecycle processors#6980
teamleaderleo wants to merge 1 commit into
open-telemetry:mainfrom
teamleaderleo:upstream/unit-11-lifecycle-fanout-v2

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Aug 6, 2026

Copy link
Copy Markdown

Which problem is this PR solving?

Trace and log processor fanout can skip processors that were present when shutdown() or forceFlush() began.

A processor that throws synchronously can stop construction of later promise inputs. A processor can also mutate the retained processor array during fanout and remove another processor from the current operation. In TracerProvider.forceFlush(), a synchronous throw can bypass the normal rejection path and leave that processor's timeout armed until expiry.

This change keeps the existing result and error policies while ensuring every processor in the opening set receives its lifecycle call. It adds no dependencies and makes no public API or configuration changes.

Fixes #6977

Short description of the changes

  • Snapshot trace and log processor lists before lifecycle fanout begins.
  • Convert direct synchronous lifecycle throws into rejected promises.
  • Preserve the existing trace, logs, and provider settlement policies.
  • Clear TracerProvider.forceFlush() timers through the existing failure path.
  • Add regression tests for synchronous throws, opening-set mutation, timer cleanup, error shape, and genuine timeout behavior.

Metrics remains out of scope because its collector list is internally constructed and its lifecycle methods already cross an asynchronous boundary.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Eleven regression tests cover:

  • MultiSpanProcessor.forceFlush() and shutdown();
  • MultiLogRecordProcessor.forceFlush() and shutdown();
  • direct synchronous throws without skipping later processors;
  • mutation of the caller-retained processor array;
  • provider error-array preservation and timeout cleanup;
  • a genuinely non-settling processor still timing out.

The candidate tree has passed the repository's Unit Tests, Lint, E2E, Bundler, W3C Trace Context, CodeQL, API peer-dependency, and security-analysis workflows.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation is not required because this change does not alter public APIs or configuration

Changelog entries are included for the stable trace SDK and experimental logs SDK.

@teamleaderleo
teamleaderleo requested a review from a team as a code owner August 6, 2026 04:49
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 6, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: teamleaderleo / name: Leo Li (625e900)

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Welcome, contributor! Thank you for your contribution to opentelemetry-js.

Important reminders:

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 6, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-08-21 01:37 UTC

Review the latest changes.

Also blocked by: Merge conflicts.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@teamleaderleo
teamleaderleo force-pushed the upstream/unit-11-lifecycle-fanout-v2 branch from 625e900 to 3c339f2 Compare August 6, 2026 05:11
Signed-off-by: Leo Li <cheerleaderleo@outlook.com>
Assisted-by: ChatGPT GPT-5.6 Thinking
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.

Lifecycle fanout can skip processors present at operation start

1 participant