Skip to content

feat(plugin): add urllib3 2.x support for Python 3.12+#387

Merged
wu-sheng merged 1 commit intomasterfrom
feat/urllib3-v2-plugin
Apr 12, 2026
Merged

feat(plugin): add urllib3 2.x support for Python 3.12+#387
wu-sheng merged 1 commit intomasterfrom
feat/urllib3-v2-plugin

Conversation

@wu-sheng
Copy link
Copy Markdown
Member

Summary

Add sw_urllib3_v2 plugin for urllib3 2.x, which removed urllib3.request.RequestMethods that the existing sw_urllib3 plugin hooks.

Changes

  • New plugin skywalking/plugins/sw_urllib3_v2.py: hooks PoolManager.request (urllib3 2.x entry point)
  • Existing plugin sw_urllib3.py: add >=3.12: [] to skip testing 1.x on Python 3.12+ (can't install)
  • Shared test: tests/plugin/http/sw_urllib3/test_urllib3.py merges version vectors from both plugins

Auto-detection

Both plugins are discovered by the agent. Only one activates based on the installed urllib3 version:

  • urllib3 1.x: sw_urllib3 succeeds (imports RequestMethods). sw_urllib3_v2 detects 1.x and returns early.
  • urllib3 2.x: sw_urllib3 fails (ImportError, skipped). sw_urllib3_v2 hooks PoolManager.request.

Verified locally (Python 3.13, span data validated)

  • urllib3==2.3 — PASSED
  • urllib3==2.0 — PASSED

Test plan

  • Plugin tests pass on Python 3.10/3.11 (urllib3 1.x via sw_urllib3)
  • Plugin tests pass on Python 3.12/3.13/3.14 (urllib3 2.x via sw_urllib3_v2)
  • No double-hooking when both plugins are loaded

🤖 Generated with Claude Code

urllib3 2.x removed `urllib3.request.RequestMethods` which the existing
plugin hooks. Add a new plugin `sw_urllib3_v2` that hooks
`PoolManager.request` directly (the 2.x entry point).

Auto-detection logic:
- sw_urllib3: tries `from urllib3.request import RequestMethods`.
  Succeeds on 1.x, fails on 2.x (skipped).
- sw_urllib3_v2: checks if `RequestMethods` exists.
  If yes (1.x), returns early. If no (2.x), hooks PoolManager.

Both plugins share the same test directory. The test merges
version vectors from both plugins' support_matrix.

Verified locally on Python 3.13:
- urllib3==2.3 PASSED (span validation)
- urllib3==2.0 PASSED (span validation)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wu-sheng wu-sheng requested a review from kezhenxu94 April 12, 2026 00:49
@wu-sheng wu-sheng added this to the 1.3.0 milestone Apr 12, 2026
@wu-sheng wu-sheng requested a review from CodePrometheus April 12, 2026 00:53
@wu-sheng
Copy link
Copy Markdown
Member Author

As new skills are ready, I could forward the plugin support scope faster and nearly no human involved.

@wu-sheng wu-sheng added feature New feature plugin Plugin labels Apr 12, 2026
@wu-sheng wu-sheng merged commit 78bed98 into master Apr 12, 2026
75 checks passed
@wu-sheng wu-sheng deleted the feat/urllib3-v2-plugin branch April 12, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature plugin Plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants