Skip to content

opentelemetry-sdk: fix thread leak bug in resource initialization logic - #5706

Merged
emdneto merged 4 commits into
open-telemetry:mainfrom
herin049:fix/detector-threadpool-leak
Oct 6, 2026
Merged

emdneto merged 4 commits into
open-telemetry:mainfrom
herin049:fix/detector-threadpool-leak

Conversation

@herin049

Copy link
Copy Markdown
Contributor

Description

Fixes bug where threads used for resource detection can be leaked for long running resource detectors.

Fixes #5697

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Tox

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@herin049
herin049 requested a review from a team as a code owner September 28, 2026 17:53
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-06 13:55 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

shutdown(wait=True) can make initialization hang indefinitely, removing the documented timeout bound.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes leaked threads from long-running resource detectors by joining executor workers during resource initialization.

Changes:

  • Updates executor shutdown behavior.
  • Adds regression coverage for worker cleanup.
  • Adds a changelog entry.
File Summary
opentelemetry-sdk/​tests/​resources/​test_resources.py Tests detector worker-thread cleanup.
opentelemetry-sdk/​src/​opentelemetry/​sdk/​resources/​__init__.py Joins detector executor threads.
.changelog/​5706.fixed Documents the thread-leak fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@herin049
herin049 requested a review from pmcollins October 6, 2026 00:54
@github-project-automation github-project-automation Bot moved this to Approved PRs in Python PR digest Oct 6, 2026
@emdneto
emdneto added this pull request to the merge queue Oct 6, 2026
Merged via the queue into open-telemetry:main with commit d996331 Oct 6, 2026
577 checks passed
emdneto added a commit that referenced this pull request Oct 6, 2026
…ic (#5706) (#5748)

* opentelemetry-sdk: fix thread leak bug in resource initialization logic

* add changelog fragment

Co-authored-by: Lukas Hering <40302054+herin049@users.noreply.github.com>
Co-authored-by: Emídio <9735060+emdneto@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

5 participants