Skip to content

Commit da23559

Browse files
committed
Remove use of httpbin
This is done in order to prevent confusion. We are trying to stop using httpbin.org for our tests. Even when the tests for the requests instrumentation do not actually perform any request to httpbin.org, because the test requests are being mocked somehow having the string httpbin.org in the tests can cause confusion and make the reader think the tests are actually making external requests to httpbin.org. Fixes open-telemetry#1844 open-telemetry#1843 open-telemetry#1845 open-telemetry#1846 open-telemetry#1847 open-telemetry#1848
1 parent 2edcc21 commit da23559

File tree

10 files changed

+56
-56
lines changed

10 files changed

+56
-56
lines changed

instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -705,11 +705,11 @@ def test_response_attributes_invalid_status_code(self):
705705
self.assertEqual(self.span.set_status.call_count, 1)
706706

707707
def test_credential_removal(self):
708-
self.scope["server"] = ("username:password@httpbin.org", 80)
708+
self.scope["server"] = ("username:password@mock", 80)
709709
self.scope["path"] = "/status/200"
710710
attrs = otel_asgi.collect_request_attributes(self.scope)
711711
self.assertEqual(
712-
attrs[SpanAttributes.HTTP_URL], "http://httpbin.org/status/200"
712+
attrs[SpanAttributes.HTTP_URL], "http://mock/status/200"
713713
)
714714

715715
def test_collect_target_attribute_missing(self):

instrumentation/opentelemetry-instrumentation-httpx/README.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ When using the instrumentor, all clients will automatically trace requests.
3030
import httpx
3131
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
3232
33-
url = "https://httpbin.org/get"
33+
url = "https://some.url/get"
3434
HTTPXClientInstrumentor().instrument()
3535
3636
with httpx.Client() as client:
@@ -51,7 +51,7 @@ use the `instrument_client` method.
5151
import httpx
5252
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
5353
54-
url = "https://httpbin.org/get"
54+
url = "https://some.url/get"
5555
5656
with httpx.Client(transport=telemetry_transport) as client:
5757
HTTPXClientInstrumentor.instrument_client(client)
@@ -96,7 +96,7 @@ If you don't want to use the instrumentor class, you can use the transport class
9696
SyncOpenTelemetryTransport,
9797
)
9898
99-
url = "https://httpbin.org/get"
99+
url = "https://some.url/get"
100100
transport = httpx.HTTPTransport()
101101
telemetry_transport = SyncOpenTelemetryTransport(transport)
102102

instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import httpx
2626
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
2727
28-
url = "https://httpbin.org/get"
28+
url = "https://some.url/get"
2929
HTTPXClientInstrumentor().instrument()
3030
3131
with httpx.Client() as client:
@@ -46,7 +46,7 @@
4646
import httpx
4747
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
4848
49-
url = "https://httpbin.org/get"
49+
url = "https://some.url/get"
5050
5151
with httpx.Client(transport=telemetry_transport) as client:
5252
HTTPXClientInstrumentor.instrument_client(client)
@@ -91,7 +91,7 @@
9191
SyncOpenTelemetryTransport,
9292
)
9393
94-
url = "https://httpbin.org/get"
94+
url = "https://some.url/get"
9595
transport = httpx.HTTPTransport()
9696
telemetry_transport = SyncOpenTelemetryTransport(transport)
9797

instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class BaseTestCases:
9797
class BaseTest(TestBase, metaclass=abc.ABCMeta):
9898
# pylint: disable=no-member
9999

100-
URL = "http://httpbin.org/status/200"
100+
URL = "http://mock/status/200"
101101
response_hook = staticmethod(_response_hook)
102102
request_hook = staticmethod(_request_hook)
103103
no_update_request_hook = staticmethod(_no_update_request_hook)
@@ -165,7 +165,7 @@ def test_basic_multiple(self):
165165
self.assert_span(num_spans=2)
166166

167167
def test_not_foundbasic(self):
168-
url_404 = "http://httpbin.org/status/404"
168+
url_404 = "http://mock/status/404"
169169

170170
with respx.mock:
171171
respx.get(url_404).mock(httpx.Response(404))

instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class RequestsIntegrationTestBase(abc.ABC):
6363
# pylint: disable=no-member
6464
# pylint: disable=too-many-public-methods
6565

66-
URL = "http://httpbin.org/status/200"
66+
URL = "http://mock/status/200"
6767

6868
# pylint: disable=invalid-name
6969
def setUp(self):
@@ -152,7 +152,7 @@ def response_hook(span, request_obj, response):
152152
self.assertEqual(span.attributes["response_hook_attr"], "value")
153153

154154
def test_excluded_urls_explicit(self):
155-
url_404 = "http://httpbin.org/status/404"
155+
url_404 = "http://mock/status/404"
156156
httpretty.register_uri(
157157
httpretty.GET,
158158
url_404,
@@ -194,7 +194,7 @@ def name_callback(method, url):
194194
self.assertEqual(span.name, "HTTP GET")
195195

196196
def test_not_foundbasic(self):
197-
url_404 = "http://httpbin.org/status/404"
197+
url_404 = "http://mock/status/404"
198198
httpretty.register_uri(
199199
httpretty.GET,
200200
url_404,
@@ -460,7 +460,7 @@ def perform_request(url: str, session: requests.Session = None):
460460
return session.get(url)
461461

462462
def test_credential_removal(self):
463-
new_url = "http://username:password@httpbin.org/status/200"
463+
new_url = "http://username:password@mock/status/200"
464464
self.perform_request(new_url)
465465
span = self.assert_span()
466466

instrumentation/opentelemetry-instrumentation-urllib/tests/test_metrics_instrumentation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828

2929
class TestUrllibMetricsInstrumentation(TestBase):
30-
URL = "http://httpbin.org/status/200"
31-
URL_POST = "http://httpbin.org/post"
30+
URL = "http://mock/status/200"
31+
URL_POST = "http://mock/post"
3232

3333
def setUp(self):
3434
super().setUp()

instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
class RequestsIntegrationTestBase(abc.ABC):
4747
# pylint: disable=no-member
4848

49-
URL = "http://httpbin.org/status/200"
50-
URL_TIMEOUT = "http://httpbin.org/timeout/0"
51-
URL_EXCEPTION = "http://httpbin.org/exception/0"
49+
URL = "http://mock/status/200"
50+
URL_TIMEOUT = "http://mock/timeout/0"
51+
URL_EXCEPTION = "http://mock/exception/0"
5252

5353
# pylint: disable=invalid-name
5454
def setUp(self):
@@ -83,7 +83,7 @@ def setUp(self):
8383
)
8484
httpretty.register_uri(
8585
httpretty.GET,
86-
"http://httpbin.org/status/500",
86+
"http://mock/status/500",
8787
status=500,
8888
)
8989

@@ -142,7 +142,7 @@ def test_basic(self):
142142
)
143143

144144
def test_excluded_urls_explicit(self):
145-
url_201 = "http://httpbin.org/status/201"
145+
url_201 = "http://mock/status/201"
146146
httpretty.register_uri(
147147
httpretty.GET,
148148
url_201,
@@ -172,7 +172,7 @@ def test_excluded_urls_from_env(self):
172172
self.assert_span(num_spans=1)
173173

174174
def test_not_foundbasic(self):
175-
url_404 = "http://httpbin.org/status/404/"
175+
url_404 = "http://mock/status/404/"
176176
httpretty.register_uri(
177177
httpretty.GET,
178178
url_404,
@@ -336,14 +336,14 @@ def test_custom_tracer_provider(self):
336336

337337
def test_requests_exception_with_response(self, *_, **__):
338338
with self.assertRaises(HTTPError):
339-
self.perform_request("http://httpbin.org/status/500")
339+
self.perform_request("http://mock/status/500")
340340

341341
span = self.assert_span()
342342
self.assertEqual(
343343
dict(span.attributes),
344344
{
345345
SpanAttributes.HTTP_METHOD: "GET",
346-
SpanAttributes.HTTP_URL: "http://httpbin.org/status/500",
346+
SpanAttributes.HTTP_URL: "http://mock/status/500",
347347
SpanAttributes.HTTP_STATUS_CODE: 500,
348348
},
349349
)
@@ -365,7 +365,7 @@ def test_requests_timeout_exception(self, *_, **__):
365365
self.assertEqual(span.status.status_code, StatusCode.ERROR)
366366

367367
def test_credential_removal(self):
368-
url = "http://username:password@httpbin.org/status/200"
368+
url = "http://username:password@mock/status/200"
369369

370370
with self.assertRaises(Exception):
371371
self.perform_request(url)

instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535

3636

3737
class TestURLLib3Instrumentor(TestBase):
38-
HTTP_URL = "http://httpbin.org/status/200"
39-
HTTPS_URL = "https://httpbin.org/status/200"
38+
HTTP_URL = "http://mock/status/200"
39+
HTTPS_URL = "https://mock/status/200"
4040

4141
def setUp(self):
4242
super().setUp()
@@ -123,7 +123,7 @@ def test_basic_http_success(self):
123123
self.assert_success_span(response, self.HTTP_URL)
124124

125125
def test_basic_http_success_using_connection_pool(self):
126-
pool = urllib3.HTTPConnectionPool("httpbin.org")
126+
pool = urllib3.HTTPConnectionPool("mock")
127127
response = pool.request("GET", "/status/200")
128128

129129
self.assert_success_span(response, self.HTTP_URL)
@@ -133,13 +133,13 @@ def test_basic_https_success(self):
133133
self.assert_success_span(response, self.HTTPS_URL)
134134

135135
def test_basic_https_success_using_connection_pool(self):
136-
pool = urllib3.HTTPSConnectionPool("httpbin.org")
136+
pool = urllib3.HTTPSConnectionPool("mock")
137137
response = pool.request("GET", "/status/200")
138138

139139
self.assert_success_span(response, self.HTTPS_URL)
140140

141141
def test_basic_not_found(self):
142-
url_404 = "http://httpbin.org/status/404"
142+
url_404 = "http://mock/status/404"
143143
httpretty.register_uri(httpretty.GET, url_404, status=404)
144144

145145
response = self.perform_request(url_404)
@@ -152,30 +152,30 @@ def test_basic_not_found(self):
152152
self.assertIs(trace.status.StatusCode.ERROR, span.status.status_code)
153153

154154
def test_basic_http_non_default_port(self):
155-
url = "http://httpbin.org:666/status/200"
155+
url = "http://mock:666/status/200"
156156
httpretty.register_uri(httpretty.GET, url, body="Hello!")
157157

158158
response = self.perform_request(url)
159159
self.assert_success_span(response, url)
160160

161161
def test_basic_http_absolute_url(self):
162-
url = "http://httpbin.org:666/status/200"
162+
url = "http://mock:666/status/200"
163163
httpretty.register_uri(httpretty.GET, url, body="Hello!")
164-
pool = urllib3.HTTPConnectionPool("httpbin.org", port=666)
164+
pool = urllib3.HTTPConnectionPool("mock", port=666)
165165
response = pool.request("GET", url)
166166

167167
self.assert_success_span(response, url)
168168

169169
def test_url_open_explicit_arg_parameters(self):
170-
url = "http://httpbin.org:666/status/200"
170+
url = "http://mock:666/status/200"
171171
httpretty.register_uri(httpretty.GET, url, body="Hello!")
172-
pool = urllib3.HTTPConnectionPool("httpbin.org", port=666)
172+
pool = urllib3.HTTPConnectionPool("mock", port=666)
173173
response = pool.urlopen(method="GET", url="/status/200")
174174

175175
self.assert_success_span(response, url)
176176

177177
def test_excluded_urls_explicit(self):
178-
url_201 = "http://httpbin.org/status/201"
178+
url_201 = "http://mock/status/201"
179179
httpretty.register_uri(
180180
httpretty.GET,
181181
url_201,
@@ -301,7 +301,7 @@ def url_filter(url):
301301
self.assert_success_span(response, self.HTTP_URL)
302302

303303
def test_credential_removal(self):
304-
url = "http://username:password@httpbin.org/status/200"
304+
url = "http://username:password@mock/status/200"
305305

306306
response = self.perform_request(url)
307307
self.assert_success_span(response, self.HTTP_URL)
@@ -339,7 +339,7 @@ def request_hook(span, request, headers, body):
339339
headers = {"header1": "value1", "header2": "value2"}
340340
body = "param1=1&param2=2"
341341

342-
pool = urllib3.HTTPConnectionPool("httpbin.org")
342+
pool = urllib3.HTTPConnectionPool("mock")
343343
response = pool.request(
344344
"POST", "/status/200", body=body, headers=headers
345345
)
@@ -366,7 +366,7 @@ def request_hook(span, request, headers, body):
366366

367367
body = "param1=1&param2=2"
368368

369-
pool = urllib3.HTTPConnectionPool("httpbin.org")
369+
pool = urllib3.HTTPConnectionPool("mock")
370370
response = pool.urlopen("POST", "/status/200", body)
371371

372372
self.assertEqual(b"Hello!", response.data)

0 commit comments

Comments
 (0)