|
3 | 3 | import sentry_sdk
|
4 | 4 | from http.client import HTTPConnection
|
5 | 5 |
|
| 6 | +from tests.conftest import create_mock_http_server |
| 7 | + |
6 | 8 | USE_DEFAULT_TRACES_SAMPLE_RATE = -1
|
7 | 9 |
|
8 | 10 | INCOMING_TRACE_ID = "771a43a4192642f0b136d5159a501700"
|
|
18 | 20 | ),
|
19 | 21 | }
|
20 | 22 |
|
| 23 | +PORT = create_mock_http_server() |
| 24 | + |
21 | 25 |
|
22 |
| -# |
23 | 26 | # Proper high level testing for trace propagation.
|
24 | 27 | # Testing the matrix of test cases described here:
|
25 | 28 | # https://develop.sentry.dev/sdk/telemetry/traces/trace-propagation-cheat-sheet/
|
26 |
| -# |
27 | 29 |
|
28 | 30 |
|
29 | 31 | @pytest.fixture
|
@@ -71,7 +73,7 @@ def test_no_incoming_trace_and_trace_propagation_targets_matching(
|
71 | 73 |
|
72 | 74 | with sentry_sdk.continue_trace(NO_INCOMING_HEADERS):
|
73 | 75 | with sentry_sdk.start_span(op="test", name="test"):
|
74 |
| - requests.get("http://example.com") |
| 76 | + requests.get(f"http://localhost:{PORT}") # noqa:E231 |
75 | 77 |
|
76 | 78 | # CHECK if performance data (a transaction/span) is sent to Sentry
|
77 | 79 | if traces_sample_rate == 1:
|
@@ -122,7 +124,7 @@ def test_no_incoming_trace_and_trace_propagation_targets_not_matching(
|
122 | 124 |
|
123 | 125 | with sentry_sdk.continue_trace(NO_INCOMING_HEADERS):
|
124 | 126 | with sentry_sdk.start_span(op="test", name="test"):
|
125 |
| - requests.get("http://example.com") |
| 127 | + requests.get(f"http://localhost:{PORT}") # noqa:E231 |
126 | 128 |
|
127 | 129 | # CHECK if performance data (a transaction/span) is sent to Sentry
|
128 | 130 | if traces_sample_rate == 1:
|
@@ -187,7 +189,7 @@ def test_with_incoming_trace_and_trace_propagation_targets_matching(
|
187 | 189 |
|
188 | 190 | with sentry_sdk.continue_trace(incoming_headers):
|
189 | 191 | with sentry_sdk.start_span(op="test", name="test"):
|
190 |
| - requests.get("http://example.com") |
| 192 | + requests.get(f"http://localhost:{PORT}") # noqa:E231 |
191 | 193 |
|
192 | 194 | # CHECK if performance data (a transaction/span) is sent to Sentry
|
193 | 195 | if (
|
@@ -265,7 +267,7 @@ def test_with_incoming_trace_and_trace_propagation_targets_not_matching(
|
265 | 267 |
|
266 | 268 | with sentry_sdk.continue_trace(incoming_headers):
|
267 | 269 | with sentry_sdk.start_span(op="test", name="test"):
|
268 |
| - requests.get("http://example.com") |
| 270 | + requests.get(f"http://localhost:{PORT}") # noqa:E231 |
269 | 271 |
|
270 | 272 | # CHECK if performance data (a transaction/span) is sent to Sentry
|
271 | 273 | if (
|
|
0 commit comments