Skip to content

Commit dadcd01

Browse files
authored
urllib3: Add instrumentation support for version 2 (#1879)
* urllib3: Add instrumentation support for version 2 * changelog
1 parent a1f6044 commit dadcd01

File tree

8 files changed

+17
-11
lines changed

8 files changed

+17
-11
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
([#1833](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1833))
3636
- Fix elasticsearch `Transport.perform_request` instrument wrap for elasticsearch >= 8
3737
([#1810](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1810))
38+
- `opentelemetry-instrumentation-urllib3` Add support for urllib3 version 2
39+
([#1879](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1879))
3840

3941
## Version 1.18.0/0.39b0 (2023-05-10)
4042

Diff for: instrumentation/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@
4141
| [opentelemetry-instrumentation-tornado](./opentelemetry-instrumentation-tornado) | tornado >= 5.1.1 | Yes
4242
| [opentelemetry-instrumentation-tortoiseorm](./opentelemetry-instrumentation-tortoiseorm) | tortoise-orm >= 0.17.0 | No
4343
| [opentelemetry-instrumentation-urllib](./opentelemetry-instrumentation-urllib) | urllib | Yes
44-
| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 | Yes
44+
| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 3.0.0 | Yes
4545
| [opentelemetry-instrumentation-wsgi](./opentelemetry-instrumentation-wsgi) | wsgi | Yes

Diff for: instrumentation/opentelemetry-instrumentation-urllib3/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies = [
3434

3535
[project.optional-dependencies]
3636
instruments = [
37-
"urllib3 >= 1.0.0, < 2.0.0",
37+
"urllib3 >= 1.0.0, < 3.0.0",
3838
]
3939
test = [
4040
"opentelemetry-instrumentation-urllib3[instruments]",

Diff for: instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/package.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
# limitations under the License.
1414

1515

16-
_instruments = ("urllib3 >= 1.0.0, < 2.0.0",)
16+
_instruments = ("urllib3 >= 1.0.0, < 3.0.0",)
1717

1818
_supports_metrics = True

Diff for: instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,9 @@ def response_hook(span, request, response):
328328

329329
def test_request_hook_params(self):
330330
def request_hook(span, request, headers, body):
331-
span.set_attribute("request_hook_headers", json.dumps(headers))
331+
span.set_attribute(
332+
"request_hook_headers", json.dumps(dict(headers))
333+
)
332334
span.set_attribute("request_hook_body", body)
333335

334336
URLLib3Instrumentor().uninstrument()

Diff for: instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_metrics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import httpretty
1919
import urllib3
2020
import urllib3.exceptions
21-
from urllib3.request import encode_multipart_formdata
21+
from urllib3 import encode_multipart_formdata
2222

2323
from opentelemetry.instrumentation.urllib3 import URLLib3Instrumentor
2424
from opentelemetry.test.httptest import HttpTestBase

Diff for: opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
"instrumentation": "opentelemetry-instrumentation-tortoiseorm==0.40b0.dev",
162162
},
163163
"urllib3": {
164-
"library": "urllib3 >= 1.0.0, < 2.0.0",
164+
"library": "urllib3 >= 1.0.0, < 3.0.0",
165165
"instrumentation": "opentelemetry-instrumentation-urllib3==0.40b0.dev",
166166
},
167167
}

Diff for: tox.ini

+7-5
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ envlist =
9292
pypy3-test-instrumentation-urllib
9393

9494
; opentelemetry-instrumentation-urllib3
95-
py3{7,8,9,10,11}-test-instrumentation-urllib3
96-
;pypy3-test-instrumentation-urllib3
95+
py3{7,8,9,10,11}-test-instrumentation-urllib3v{1,2}
96+
;pypy3-test-instrumentation-urllib3v{1,2}
9797

9898
; opentelemetry-instrumentation-requests
9999
py3{7,8,9,10,11}-test-instrumentation-requests
@@ -280,6 +280,8 @@ deps =
280280
httpx18: respx~=0.17.0
281281
httpx21: httpx>=0.19.0
282282
httpx21: respx~=0.20.1
283+
urllib3v1: urllib3 >=1.0.0,<2.0.0
284+
urllib3v2: urllib3 >=2.0.0,<3.0.0
283285

284286
; FIXME: add coverage testing
285287
; FIXME: add mypy testing
@@ -310,7 +312,7 @@ changedir =
310312
test-instrumentation-fastapi: instrumentation/opentelemetry-instrumentation-fastapi/tests
311313
test-instrumentation-flask{213,220}: instrumentation/opentelemetry-instrumentation-flask/tests
312314
test-instrumentation-urllib: instrumentation/opentelemetry-instrumentation-urllib/tests
313-
test-instrumentation-urllib3: instrumentation/opentelemetry-instrumentation-urllib3/tests
315+
test-instrumentation-urllib3v{1,2}: instrumentation/opentelemetry-instrumentation-urllib3/tests
314316
test-instrumentation-grpc: instrumentation/opentelemetry-instrumentation-grpc/tests
315317
test-instrumentation-jinja2: instrumentation/opentelemetry-instrumentation-jinja2/tests
316318
test-instrumentation-kafka-python: instrumentation/opentelemetry-instrumentation-kafka-python/tests
@@ -369,7 +371,7 @@ commands_pre =
369371

370372
grpc: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-grpc[test]
371373

372-
falcon{1,2,3},flask{213,220},django{1,2,3,4},pyramid,tornado,starlette,fastapi,aiohttp,asgi,requests,urllib,urllib3,wsgi: pip install {toxinidir}/util/opentelemetry-util-http[test]
374+
falcon{1,2,3},flask{213,220},django{1,2,3,4},pyramid,tornado,starlette,fastapi,aiohttp,asgi,requests,urllib,urllib3v{1,2},wsgi: pip install {toxinidir}/util/opentelemetry-util-http[test]
373375
wsgi,falcon{1,2,3},flask{213,220},django{1,2,3,4},pyramid: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-wsgi[test]
374376
asgi,django{3,4},starlette,fastapi: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-asgi[test]
375377

@@ -388,7 +390,7 @@ commands_pre =
388390

389391
urllib: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-urllib[test]
390392

391-
urllib3: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-urllib3[test]
393+
urllib3v{1,2}: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-urllib3[test]
392394

393395
botocore: pip install {toxinidir}/instrumentation/opentelemetry-instrumentation-botocore[test]
394396

0 commit comments

Comments
 (0)