Skip to content

fix(sdk): bound get_aggregated_resources wait to per-detector timeout - #5545

Open
sidsri14 wants to merge 1 commit into
open-telemetry:mainfrom
sidsri14:fix/get-aggregated-resources-timeout
Open

fix(sdk): bound get_aggregated_resources wait to per-detector timeout#5545
sidsri14 wants to merge 1 commit into
open-telemetry:mainfrom
sidsri14:fix/get-aggregated-resources-timeout

Conversation

@sidsri14

@sidsri14 sidsri14 commented Aug 13, 2026

Copy link
Copy Markdown

Summary

Fixes #5533 (Part 1). get_aggregated_resources() passes a timeout to future.result(), but the wait is not actually bounded: exiting the with concurrent.futures.ThreadPoolExecutor(...) block calls shutdown(wait=True), which joins still-running detector workers. A detector that blocks longer than timeout therefore holds up the whole call regardless of the future.result(timeout=...) bound.

The fix stops using the executor as a context manager and shuts it down explicitly with shutdown(wait=False, cancel_futures=True) in a finally block. A detector that outlives the timeout can continue in its worker thread until detect() returns, but the caller no longer waits for that worker during executor shutdown.

As noted by the reporter, this also fixes Part 2 (the forked-child wedge) as a side effect: the child's _get_process_dependent_resource() can return with the skip warning instead of hanging forever inside the at_fork handler.

Existing behavior preserved

  • Per-detector timeout, ordering, and merge semantics are unchanged.
  • raise_on_error re-raises the TimeoutError or detector exception; otherwise a warning is logged and the detector is skipped.
  • The skip warning still fires for a timed-out detector.

Test plan

  • Added test_aggregated_resources_timeout_bounds_wait: a detector sleeping for 2 seconds with timeout=0.1 returns within 1 second and logs the skip warning.
  • Focused resources suite: 56 passed, 1 skipped on Python 3.13.
  • Ruff check and format check pass for the changed source and test files.

Changelog

Added .changelog/5545.fixed.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 13, 2026

Copy link
Copy Markdown

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

  • ✅ login: sidsri14 / name: Siddharth Srivastava (7ae6a59)

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 14, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-08-14 17:10 UTC

Review the latest changes.

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.

Avoid ThreadPoolExecutor context-manager shutdown(wait=True), which defeats future.result(timeout=...) by joining detectors that outlive the timeout. Shut down without waiting so the caller returns after the configured per-detector bound; a timed-out detector may continue until detect() returns.

This also prevents a forked child from wedging in the resource refresh at-fork handler when it inherits a locked detector dependency.

Assisted-by: Claude Sonnet 4.6
@sidsri14
sidsri14 force-pushed the fix/get-aggregated-resources-timeout branch from 049a746 to 7ae6a59 Compare August 14, 2026 17:09
@sidsri14
sidsri14 marked this pull request as ready for review August 14, 2026 17:09
@sidsri14
sidsri14 requested a review from a team as a code owner August 14, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Blocked resource detector can wedge forked children: get_aggregated_resources timeout does not bound the wait

1 participant