Skip to content

NH-154949 Always detach token in case issue with requests.get - #921

Open
tammy-baylis-swi wants to merge 1 commit into
mainfrom
NH-154949-fix-detach-if-exc
Open

tammy-baylis-swi wants to merge 1 commit into
mainfrom
NH-154949-fix-detach-if-exc

Conversation

@tammy-baylis-swi

Copy link
Copy Markdown
Contributor

An agent helped me find that context cleanup (explicit token detach) by APM Python HttpSampler and UAMS detector may not succeed and persist, if exception raised by requests.get. This adds try-finally and updates unit tests.

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.

🟢 Approval recommended

No active review issues remain for the HTTP-request context-cleanup changes in the sampler and UAMS resource detector.

No open issues 🎉

What changed in this PR

This PR prevents instrumentation suppression from persisting after failed HTTP requests in the SolarWinds APM sampler and UAMS resource detector.

Changes:

  • Wraps both HTTP requests in try/finally so context tokens are always detached.
  • Adds regression tests verifying cleanup after connection errors while preserving existing error behavior.
File Description
tests/​unit/​test_uams.py Verifies context cleanup and an empty result after a connection error.
tests/​unit/​test_oboe/​test_http_sampler.py Verifies context cleanup while allowing the connection error to propagate.
solarwinds_apm/​uams.py Ensures context detachment when the UAMS request fails.
solarwinds_apm/​oboe/​http_sampler.py Ensures context detachment when the collector request fails.

Review effort: Balanced

@tammy-baylis-swi
tammy-baylis-swi marked this pull request as ready for review November 5, 2026 23:51
@tammy-baylis-swi
tammy-baylis-swi requested review from a team as code owners November 5, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants