From 76f1f23e6100b9a1361324f1116fbb93af7ddd47 Mon Sep 17 00:00:00 2001 From: Itay Gibel Date: Thu, 2 Sep 2021 14:07:31 +0300 Subject: [PATCH] adding up to date generated code --- .../instrumentation/urllib3/__init__.py | 12 +++++++----- .../tests/test_urllib3_integration.py | 13 +++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py index f8ad2c57a7..a177618358 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py @@ -191,11 +191,13 @@ def instrumented_urlopen(wrapped, instance, args, kwargs): ) -def _call_request_hook(request_hook: typing.Union[_RequestHookT, _ExtendedRequestHookT], - span: Span, - connection_pool: urllib3.connectionpool.HTTPConnectionPool, - headers: typing.Dict, - body: str): +def _call_request_hook( + request_hook: typing.Union[_RequestHookT, _ExtendedRequestHookT], + span: Span, + connection_pool: urllib3.connectionpool.HTTPConnectionPool, + headers: typing.Dict, + body: str, +): try: # First assume request_hook is a function of type _ExtendedRequestHookT request_hook(span, connection_pool, headers, body) diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py index 4504364b1f..27bdd7c7a2 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py @@ -47,7 +47,6 @@ def setUp(self): httpretty.register_uri(httpretty.GET, self.HTTPS_URL, body="Hello!") httpretty.register_uri(httpretty.POST, self.HTTP_URL, body="Hello!") - def tearDown(self): super().tearDown() URLLib3Instrumentor().uninstrument() @@ -288,21 +287,23 @@ def extended_request_hook(span, request, headers, body): span.set_attribute("request_hook_body", body) URLLib3Instrumentor().uninstrument() - URLLib3Instrumentor().instrument( - request_hook=extended_request_hook, - ) + URLLib3Instrumentor().instrument(request_hook=extended_request_hook,) headers = {"header1": "value1", "header2": "value2"} body = "param1=1¶m2=2" pool = urllib3.HTTPConnectionPool("httpbin.org") - response = pool.request("POST", "/status/200", body=body, headers=headers) + response = pool.request( + "POST", "/status/200", body=body, headers=headers + ) self.assertEqual(b"Hello!", response.data) span = self.assert_span() self.assertIn("request_hook_headers", span.attributes) - self.assertEqual(span.attributes["request_hook_headers"], json.dumps(headers)) + self.assertEqual( + span.attributes["request_hook_headers"], json.dumps(headers) + ) self.assertIn("request_hook_body", span.attributes) self.assertEqual(span.attributes["request_hook_body"], body)