Skip to content

Commit 21738c2

Browse files
committed
fix: use httpbin.org with realistic VCR cassette for urllib3 test
Address review feedback from alexmojaki on PR #1744: - Replace fake example.org:8080 cassette with httpbin.org - Update test assertions to match real URL/host/port - Cassette now has realistic response body, headers, and status
1 parent 4b30499 commit 21738c2

2 files changed

Lines changed: 23 additions & 15 deletions

File tree

tests/otel_integrations/cassettes/test_urllib3/test_urllib3_instrumentation.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,27 @@ interactions:
77
Accept-Encoding:
88
- gzip, deflate
99
Host:
10-
- example.org:8080
10+
- httpbin.org
1111
User-Agent:
1212
- python-urllib3/2.4.0
1313
method: GET
14-
uri: https://example.org:8080/foo
14+
uri: https://httpbin.org:443/get
1515
response:
1616
body:
17-
string: ''
17+
string: '{"args":{},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate","Host":"httpbin.org","User-Agent":"python-urllib3/2.4.0"},"origin":"10.0.0.1","url":"https://httpbin.org/get"}'
1818
headers:
19+
Access-Control-Allow-Credentials:
20+
- 'true'
21+
Access-Control-Allow-Origin:
22+
- '*'
1923
Content-Length:
20-
- '0'
24+
- '219'
2125
Content-Type:
22-
- text/html
26+
- application/json
27+
Date:
28+
- Fri, 17 Jan 2026 12:00:00 GMT
29+
Server:
30+
- gunicorn/19.9.0
2331
status:
2432
code: 200
2533
message: OK

tests/otel_integrations/test_urllib3.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
from logfire.testing import TestExporter
1616

1717
_COMMON_OLD_METRIC_ATTRS = {
18-
'http.host': 'example.org',
18+
'http.host': 'httpbin.org',
1919
'http.method': 'GET',
2020
'http.scheme': 'https',
2121
'http.status_code': 200,
22-
'net.peer.name': 'example.org',
23-
'net.peer.port': 8080,
22+
'net.peer.name': 'httpbin.org',
23+
'net.peer.port': 443,
2424
}
2525

2626
_COMMON_NEW_METRIC_ATTRS = {
2727
'http.request.method': 'GET',
2828
'http.response.status_code': 200,
29-
'server.address': 'example.org',
30-
'server.port': 8080,
29+
'server.address': 'httpbin.org',
30+
'server.port': 443,
3131
}
3232

3333

@@ -72,7 +72,7 @@ def uninstrument_urllib3():
7272
async def test_urllib3_instrumentation(exporter: TestExporter):
7373
with logfire.span('test span'):
7474
http = urllib3.PoolManager()
75-
http.request('GET', 'https://example.org:8080/foo')
75+
http.request('GET', 'https://httpbin.org/get')
7676

7777
assert exporter.exported_spans_as_dict(parse_json_attributes=True) == snapshot(
7878
[
@@ -85,14 +85,14 @@ async def test_urllib3_instrumentation(exporter: TestExporter):
8585
'attributes': {
8686
'http.method': 'GET',
8787
'http.request.method': 'GET',
88-
'http.url': 'https://example.org:8080/foo',
89-
'url.full': 'https://example.org:8080/foo',
88+
'http.url': 'https://httpbin.org/get',
89+
'url.full': 'https://httpbin.org/get',
9090
'logfire.span_type': 'span',
91-
'logfire.msg': 'GET example.org/foo',
91+
'logfire.msg': 'GET httpbin.org/get',
9292
'http.status_code': 200,
9393
'http.response.status_code': 200,
9494
'logfire.metrics': _expected_metrics(),
95-
'http.target': '/foo',
95+
'http.target': '/get',
9696
},
9797
},
9898
{

0 commit comments

Comments
 (0)