diff --git a/.python-version b/.python-version deleted file mode 100644 index 11aaa06863..0000000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.9.5 diff --git a/dev-requirements.txt b/dev-requirements.txt index 2bb9e32149..8cf75f632c 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ pylint<2.10 flake8~=3.7 isort~=5.6 -black>=19.3b0,==19.* +black>=21.10b0 httpretty~=1.0 mypy==0.790 sphinx diff --git a/docs/conf.py b/docs/conf.py index 20f5393a21..73cb96f94a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -129,12 +129,22 @@ def getlistcfg(strval): if "class_references" in mcfg: class_references = getlistcfg(mcfg["class_references"]) for class_reference in class_references: - nitpick_ignore.append(("py:class", class_reference,)) + nitpick_ignore.append( + ( + "py:class", + class_reference, + ) + ) if "anys" in mcfg: anys = getlistcfg(mcfg["anys"]) for _any in anys: - nitpick_ignore.append(("any", _any,)) + nitpick_ignore.append( + ( + "any", + _any, + ) + ) # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] diff --git a/exporter/opentelemetry-exporter-datadog/src/opentelemetry/exporter/datadog/propagator.py b/exporter/opentelemetry-exporter-datadog/src/opentelemetry/exporter/datadog/propagator.py index db008c903a..7c22827e05 100644 --- a/exporter/opentelemetry-exporter-datadog/src/opentelemetry/exporter/datadog/propagator.py +++ b/exporter/opentelemetry-exporter-datadog/src/opentelemetry/exporter/datadog/propagator.py @@ -96,7 +96,9 @@ def inject( return sampled = (trace.TraceFlags.SAMPLED & span.context.trace_flags) != 0 setter.set( - carrier, self.TRACE_ID_KEY, format_trace_id(span.context.trace_id), + carrier, + self.TRACE_ID_KEY, + format_trace_id(span.context.trace_id), ) setter.set( carrier, self.PARENT_ID_KEY, format_span_id(span.context.span_id) diff --git a/exporter/opentelemetry-exporter-datadog/tests/test_datadog_exporter.py b/exporter/opentelemetry-exporter-datadog/tests/test_datadog_exporter.py index ef34836305..c388b23c4a 100644 --- a/exporter/opentelemetry-exporter-datadog/tests/test_datadog_exporter.py +++ b/exporter/opentelemetry-exporter-datadog/tests/test_datadog_exporter.py @@ -78,7 +78,8 @@ def test_constructor_explicit(self): """Test the constructor passing all the options.""" agent_url = "http://localhost:8126" exporter = datadog.DatadogSpanExporter( - agent_url=agent_url, service="explicit", + agent_url=agent_url, + service="explicit", ) self.assertEqual(exporter.agent_url, agent_url) @@ -472,7 +473,8 @@ def test_span_processor_dropped_spans(self): tracer_provider.shutdown() @mark.skipif( - sys.platform == "win32", reason="unreliable test on windows", + sys.platform == "win32", + reason="unreliable test on windows", ) def test_span_processor_scheduled_delay(self): """Test that spans are exported each schedule_delay_millis""" diff --git a/exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/__init__.py b/exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/__init__.py index 38cfac0f68..e373ab87b2 100644 --- a/exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/__init__.py +++ b/exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/__init__.py @@ -132,7 +132,8 @@ class RichConsoleSpanExporter(SpanExporter): """ def __init__( - self, service_name: Optional[str] = None, + self, + service_name: Optional[str] = None, ): self.service_name = service_name self.console = Console() diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py index a89b3a2220..0c5a695bda 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py @@ -201,7 +201,8 @@ async def on_request_start( request_span_name = f"HTTP {http_method}" trace_config_ctx.span = trace_config_ctx.tracer.start_span( - request_span_name, kind=SpanKind.CLIENT, + request_span_name, + kind=SpanKind.CLIENT, ) if callable(request_hook): diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py index aede6228b6..30f283a007 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py @@ -116,7 +116,10 @@ def test_status_codes(self): (HTTPStatus.OK, StatusCode.UNSET), (HTTPStatus.TEMPORARY_REDIRECT, StatusCode.UNSET), (HTTPStatus.SERVICE_UNAVAILABLE, StatusCode.ERROR), - (HTTPStatus.GATEWAY_TIMEOUT, StatusCode.ERROR,), + ( + HTTPStatus.GATEWAY_TIMEOUT, + StatusCode.ERROR, + ), ): with self.subTest(status_code=status_code): host, port = self._http_request( @@ -178,7 +181,8 @@ def response_hook( host, port = self._http_request( trace_config=aiohttp_client.create_trace_config( - request_hook=request_hook, response_hook=response_hook, + request_hook=request_hook, + response_hook=response_hook, ), method=method, url=path, diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py index 7ef3876d3c..1d51d14d5b 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py @@ -91,7 +91,7 @@ def _instrument(self, **kwargs): # pylint:disable=no-self-use def _uninstrument(self, **kwargs): - """"Disable aiopg instrumentation""" + """ "Disable aiopg instrumentation""" wrappers.unwrap_connect() wrappers.unwrap_create_pool() diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py index e077743a18..07c21ac23f 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -299,7 +299,8 @@ async def __call__(self, scope, receive, send): try: with self.tracer.start_as_current_span( - span_name, kind=trace.SpanKind.SERVER, + span_name, + kind=trace.SpanKind.SERVER, ) as span: if span.is_recording(): attributes = collect_request_attributes(scope) diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py index 33a4d94bc9..2df4359a65 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py @@ -130,15 +130,15 @@ def _determine_parent_context( ) -> Context: """Determine the parent context for the current Lambda invocation. - See more: - https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/instrumentation/aws-lambda.md#determining-the-parent-of-a-span + See more: + https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/instrumentation/aws-lambda.md#determining-the-parent-of-a-span - Args: - lambda_event: user-defined, so it could be anything, but this - method counts it being a map with a 'headers' key - Returns: - A Context with configuration found in the carrier. - """ + Args: + lambda_event: user-defined, so it could be anything, but this + method counts it being a map with a 'headers' key + Returns: + A Context with configuration found in the carrier. + """ parent_context = None xray_env_var = os.environ.get(_X_AMZN_TRACE_ID) @@ -194,7 +194,9 @@ def _instrumented_lambda_handler_call( tracer = get_tracer(__name__, __version__, tracer_provider) with tracer.start_as_current_span( - name=orig_handler_name, context=parent_context, kind=span_kind, + name=orig_handler_name, + context=parent_context, + kind=span_kind, ) as span: if span.is_recording(): lambda_context = args[1] diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py index e1d033c303..270925e2f1 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py @@ -93,7 +93,8 @@ class TestAwsLambdaInstrumentor(TestBase): def setUp(self): super().setUp() self.common_env_patch = mock.patch.dict( - "os.environ", {_HANDLER: "mocks.lambda_function.handler"}, + "os.environ", + {_HANDLER: "mocks.lambda_function.handler"}, ) self.common_env_patch.start() diff --git a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py index 61302dbae8..757ff95f03 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py @@ -123,7 +123,8 @@ def _common_request( # pylint: disable=too-many-locals endpoint_name = getattr(instance, "host").split(".")[0] with self._tracer.start_as_current_span( - f"{endpoint_name}.command", kind=SpanKind.CONSUMER, + f"{endpoint_name}.command", + kind=SpanKind.CONSUMER, ) as span: span.set_attribute("endpoint", endpoint_name) if args: @@ -135,7 +136,11 @@ def _common_request( # pylint: disable=too-many-locals if span.is_recording(): add_span_arg_tags( - span, endpoint_name, args, args_name, traced_args, + span, + endpoint_name, + args, + args_name, + traced_args, ) # Obtaining region name diff --git a/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_instrumentation.py b/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_instrumentation.py index 70bb703cb3..3628b42709 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_instrumentation.py @@ -99,7 +99,11 @@ def assert_only_span(self): return spans[0] def assert_span( - self, service: str, operation: str, request_id=None, attributes=None, + self, + service: str, + operation: str, + request_id=None, + attributes=None, ): span = self.assert_only_span() expected = self._default_span_attributes(service, operation) diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py index 8e6e3913a8..bc5ca850bd 100644 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py @@ -131,7 +131,9 @@ def _instrument(self, **kwargs): tracer_provider = kwargs.get("tracer_provider") tracer = get_tracer( - __name__, __version__, tracer_provider=tracer_provider, + __name__, + __version__, + tracer_provider=tracer_provider, ) _DjangoMiddleware._tracer = tracer diff --git a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py index b361d78b44..473a0fb3c0 100644 --- a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py @@ -356,19 +356,23 @@ async def test_trace_parent(self): traceparent_value = f"00-{trace_id}-{span_id}-01" Client().get( - "/span_name/1234/", traceparent=traceparent_value, + "/span_name/1234/", + traceparent=traceparent_value, ) span = self.memory_exporter.get_finished_spans()[0] self.assertEqual( - trace_id, format_trace_id(span.get_span_context().trace_id), + trace_id, + format_trace_id(span.get_span_context().trace_id), ) self.assertIsNotNone(span.parent) self.assertEqual( - trace_id, format_trace_id(span.parent.trace_id), + trace_id, + format_trace_id(span.parent.trace_id), ) self.assertEqual( - span_id, format_span_id(span.parent.span_id), + span_id, + format_span_id(span.parent.span_id), ) self.memory_exporter.clear() @@ -382,7 +386,8 @@ def test_trace_response_headers(self): response = Client().get("/span_name/1234/") self.assertTraceResponseHeaderMatchesSpan( - response, self.memory_exporter.get_finished_spans()[0], + response, + self.memory_exporter.get_finished_spans()[0], ) self.memory_exporter.clear() diff --git a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware_asgi.py b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware_asgi.py index a82d167a5a..3d8d557bcc 100644 --- a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware_asgi.py +++ b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware_asgi.py @@ -330,19 +330,23 @@ async def test_trace_parent(self): traceparent_value = f"00-{trace_id}-{span_id}-01" await self.async_client.get( - "/span_name/1234/", traceparent=traceparent_value, + "/span_name/1234/", + traceparent=traceparent_value, ) span = self.memory_exporter.get_finished_spans()[0] self.assertEqual( - trace_id, format_trace_id(span.get_span_context().trace_id), + trace_id, + format_trace_id(span.get_span_context().trace_id), ) self.assertIsNotNone(span.parent) self.assertEqual( - trace_id, format_trace_id(span.parent.trace_id), + trace_id, + format_trace_id(span.parent.trace_id), ) self.assertEqual( - span_id, format_span_id(span.parent.span_id), + span_id, + format_span_id(span.parent.span_id), ) self.memory_exporter.clear() @@ -359,7 +363,8 @@ async def test_trace_response_headers(self): self.assertTrue(response.has_header("traceresponse")) self.assertEqual( - response["Access-Control-Expose-Headers"], "traceresponse", + response["Access-Control-Expose-Headers"], + "traceresponse", ) self.assertEqual( response["traceresponse"], diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py index 44763fa9f7..cdd49fe1d7 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py @@ -119,7 +119,8 @@ class ElasticsearchInstrumentor(BaseInstrumentor): def __init__(self, span_name_prefix=None): if not span_name_prefix: span_name_prefix = environ.get( - "OTEL_PYTHON_ELASTICSEARCH_NAME_PREFIX", "Elasticsearch", + "OTEL_PYTHON_ELASTICSEARCH_NAME_PREFIX", + "Elasticsearch", ) self._span_name_prefix = span_name_prefix.strip() super().__init__() @@ -187,7 +188,8 @@ def wrapper(wrapped, _, args, kwargs): body = kwargs.get("body", None) with tracer.start_as_current_span( - op_name, kind=SpanKind.CLIENT, + op_name, + kind=SpanKind.CLIENT, ) as span: if callable(request_hook): @@ -215,7 +217,8 @@ def wrapper(wrapped, _, args, kwargs): for member in _ATTRIBUTES_FROM_RESULT: if member in rv: span.set_attribute( - f"elasticsearch.{member}", str(rv[member]), + f"elasticsearch.{member}", + str(rv[member]), ) if callable(response_hook): diff --git a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py index 58d241f0b0..769f831209 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py @@ -222,7 +222,9 @@ def _start_response(status, response_headers, *args, **kwargs): return super().__call__(env, _start_response) except Exception as exc: activation.__exit__( - type(exc), exc, getattr(exc, "__traceback__", None), + type(exc), + exc, + getattr(exc, "__traceback__", None), ) context.detach(token) raise diff --git a/instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py b/instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py index 9e3fc0ec31..f971ec68a0 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py @@ -88,7 +88,8 @@ def _test_method(self, method): self.assertEqual(span.name, f"HelloWorldResource.on_{method.lower()}") self.assertEqual(span.status.status_code, StatusCode.UNSET) self.assertEqual( - span.status.description, None, + span.status.description, + None, ) self.assertSpanHasAttributes( span, diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py index a11ffea33a..97bd1e9c9e 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py @@ -254,7 +254,8 @@ def _create_app_explicit_excluded_urls(self): to_exclude = "/user/123,/foobar" self._instrumentor.uninstrument() # Disable previous instrumentation (setUp) self._instrumentor.instrument( - tracer_provider=tracer_provider, excluded_urls=to_exclude, + tracer_provider=tracer_provider, + excluded_urls=to_exclude, ) return self._create_fastapi_app() diff --git a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py index 7466542a0d..b663829476 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py @@ -326,7 +326,9 @@ def instrument_app( tracer = trace.get_tracer(__name__, __version__, tracer_provider) _before_request = _wrapped_before_request( - request_hook, tracer, excluded_urls=excluded_urls, + request_hook, + tracer, + excluded_urls=excluded_urls, ) app._before_request = _before_request app.before_request(_before_request) diff --git a/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py b/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py index 21fd23982a..50dd188af1 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py +++ b/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py @@ -157,7 +157,8 @@ def test_trace_response(self): self.assertEqual(len(span_list), 1) self.assertTraceResponseHeaderMatchesSpan( - response.headers, span_list[0], + response.headers, + span_list[0], ) set_global_response_propagator(orig) diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py index dcc92ae287..f6de2a2d76 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py @@ -206,7 +206,9 @@ def instrumentation_dependencies(self) -> Collection[str]: def _instrument(self, **kwargs): for ctype in self._which_channel(kwargs): _wrap( - "grpc", ctype, self.wrapper_fn, + "grpc", + ctype, + self.wrapper_fn, ) def _uninstrument(self, **kwargs): @@ -217,7 +219,8 @@ def wrapper_fn(self, original_func, instance, args, kwargs): channel = original_func(*args, **kwargs) tracer_provider = kwargs.get("tracer_provider") return intercept_channel( - channel, client_interceptor(tracer_provider=tracer_provider), + channel, + client_interceptor(tracer_provider=tracer_provider), ) diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py index 7cefcfe3e7..b67b1571b5 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py @@ -122,7 +122,8 @@ def abort(self, code, details): ) self._active_span.set_status( Status( - status_code=StatusCode.ERROR, description=f"{code}:{details}", + status_code=StatusCode.ERROR, + description=f"{code}:{details}", ) ) return self._servicer_context.abort(code, details) diff --git a/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor.py b/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor.py index e0970994e6..318f36c4d0 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor.py @@ -230,7 +230,8 @@ def test_error_simple(self): self.assertEqual(len(spans), 1) span = spans[0] self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) def test_error_stream_unary(self): @@ -241,7 +242,8 @@ def test_error_stream_unary(self): self.assertEqual(len(spans), 1) span = spans[0] self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) def test_error_unary_stream(self): @@ -252,7 +254,8 @@ def test_error_unary_stream(self): self.assertEqual(len(spans), 1) span = spans[0] self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) def test_error_stream_stream(self): @@ -263,7 +266,8 @@ def test_error_stream_stream(self): self.assertEqual(len(spans), 1) span = spans[0] self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) def test_client_interceptor_trace_context_propagation( diff --git a/instrumentation/opentelemetry-instrumentation-grpc/tests/test_server_interceptor.py b/instrumentation/opentelemetry-instrumentation-grpc/tests/test_server_interceptor.py index 2ab84c8651..03e063aa0d 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/tests/test_server_interceptor.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/tests/test_server_interceptor.py @@ -64,14 +64,16 @@ class Servicer(GRPCTestServerServicer): # pylint:disable=C0103 def SimpleMethod(self, request, context): return Response( - server_id=request.client_id, response_data=request.request_data, + server_id=request.client_id, + response_data=request.request_data, ) # pylint:disable=C0103 def ServerStreamingMethod(self, request, context): for data in ("one", "two", "three"): yield Response( - server_id=request.client_id, response_data=data, + server_id=request.client_id, + response_data=data, ) @@ -84,7 +86,8 @@ def handler(request, context): grpc_server_instrumentor.instrument() with futures.ThreadPoolExecutor(max_workers=1) as executor: server = grpc.server( - executor, options=(("grpc.so_reuseport", 0),), + executor, + options=(("grpc.so_reuseport", 0),), ) server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),)) @@ -136,7 +139,8 @@ def handler(request, context): grpc_server_instrumentor.uninstrument() with futures.ThreadPoolExecutor(max_workers=1) as executor: server = grpc.server( - executor, options=(("grpc.so_reuseport", 0),), + executor, + options=(("grpc.so_reuseport", 0),), ) server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),)) @@ -351,7 +355,8 @@ def ServerStreamingMethod(self, request, context): for data in ("one", "two", "three"): yield Response( - server_id=request.client_id, response_data=data, + server_id=request.client_id, + response_data=data, ) # Intercept gRPC calls... diff --git a/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py b/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py index 1eacad500d..4c4705dc98 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py +++ b/instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py @@ -58,7 +58,8 @@ def _async_call(coro: typing.Coroutine) -> asyncio.Task: def _response_hook(span, request: "RequestInfo", response: "ResponseInfo"): span.set_attribute( - HTTP_RESPONSE_BODY, response[2].read(), + HTTP_RESPONSE_BODY, + response[2].read(), ) @@ -66,7 +67,8 @@ async def _async_response_hook( span: "Span", request: "RequestInfo", response: "ResponseInfo" ): span.set_attribute( - HTTP_RESPONSE_BODY, await response[2].aread(), + HTTP_RESPONSE_BODY, + await response[2].aread(), ) @@ -175,7 +177,8 @@ def test_not_foundbasic(self): span.attributes.get(SpanAttributes.HTTP_STATUS_CODE), 404 ) self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) def test_suppress_instrumentation(self): @@ -553,7 +556,8 @@ def create_transport( return telemetry_transport def create_client( - self, transport: typing.Optional[SyncOpenTelemetryTransport] = None, + self, + transport: typing.Optional[SyncOpenTelemetryTransport] = None, ): return httpx.Client(transport=transport) @@ -595,7 +599,8 @@ def create_transport( return telemetry_transport def create_client( - self, transport: typing.Optional[AsyncOpenTelemetryTransport] = None, + self, + transport: typing.Optional[AsyncOpenTelemetryTransport] = None, ): return httpx.AsyncClient(transport=transport) @@ -619,7 +624,8 @@ async def _perform_request(): class TestSyncInstrumentationIntegration(BaseTestCases.BaseInstrumentorTest): def create_client( - self, transport: typing.Optional[SyncOpenTelemetryTransport] = None, + self, + transport: typing.Optional[SyncOpenTelemetryTransport] = None, ): return httpx.Client() @@ -641,7 +647,8 @@ class TestAsyncInstrumentationIntegration(BaseTestCases.BaseInstrumentorTest): no_update_request_hook = staticmethod(_async_no_update_request_hook) def create_client( - self, transport: typing.Optional[AsyncOpenTelemetryTransport] = None, + self, + transport: typing.Optional[AsyncOpenTelemetryTransport] = None, ): return httpx.AsyncClient() diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py b/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py index 6076d512a3..735f808e90 100644 --- a/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py @@ -74,7 +74,8 @@ def wrapper(wrapped, instance, args, kwargs): def _wrap_render(tracer, wrapped, instance, args, kwargs): """Wrap `Template.render()` or `Template.generate()`""" with tracer.start_as_current_span( - "jinja2.render", kind=SpanKind.INTERNAL, + "jinja2.render", + kind=SpanKind.INTERNAL, ) as span: if span.is_recording(): template_name = instance.name or DEFAULT_TEMPLATE_NAME @@ -85,7 +86,8 @@ def _wrap_render(tracer, wrapped, instance, args, kwargs): @_with_tracer_wrapper def _wrap_compile(tracer, wrapped, _, args, kwargs): with tracer.start_as_current_span( - "jinja2.compile", kind=SpanKind.INTERNAL, + "jinja2.compile", + kind=SpanKind.INTERNAL, ) as span: if span.is_recording(): template_name = ( @@ -100,7 +102,8 @@ def _wrap_compile(tracer, wrapped, _, args, kwargs): @_with_tracer_wrapper def _wrap_load_template(tracer, wrapped, _, args, kwargs): with tracer.start_as_current_span( - "jinja2.load", kind=SpanKind.INTERNAL, + "jinja2.load", + kind=SpanKind.INTERNAL, ) as span: if span.is_recording(): template_name = kwargs.get("name", args[0]) diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/tests/test_jinja2.py b/instrumentation/opentelemetry-instrumentation-jinja2/tests/test_jinja2.py index 6591e0114f..24ccc7dbd2 100644 --- a/instrumentation/opentelemetry-instrumentation-jinja2/tests/test_jinja2.py +++ b/instrumentation/opentelemetry-instrumentation-jinja2/tests/test_jinja2.py @@ -86,13 +86,15 @@ def test_render_inline_template(self): self.assertEqual(template.name, "jinja2.compile") self.assertIs(template.kind, trace_api.SpanKind.INTERNAL) self.assertEqual( - template.attributes, {"jinja2.template_name": ""}, + template.attributes, + {"jinja2.template_name": ""}, ) self.assertEqual(render.name, "jinja2.render") self.assertIs(render.kind, trace_api.SpanKind.INTERNAL) self.assertEqual( - render.attributes, {"jinja2.template_name": ""}, + render.attributes, + {"jinja2.template_name": ""}, ) def test_generate_inline_template_with_root(self): @@ -127,13 +129,15 @@ def test_generate_inline_template(self): self.assertEqual(template.name, "jinja2.compile") self.assertIs(template.kind, trace_api.SpanKind.INTERNAL) self.assertEqual( - template.attributes, {"jinja2.template_name": ""}, + template.attributes, + {"jinja2.template_name": ""}, ) self.assertEqual(generate.name, "jinja2.render") self.assertIs(generate.kind, trace_api.SpanKind.INTERNAL) self.assertEqual( - generate.attributes, {"jinja2.template_name": ""}, + generate.attributes, + {"jinja2.template_name": ""}, ) def test_file_template_with_root(self): @@ -179,7 +183,8 @@ def test_file_template(self): self.assertEqual(render.name, "jinja2.render") self.assertEqual( - compile2.attributes, {"jinja2.template_name": "template.html"}, + compile2.attributes, + {"jinja2.template_name": "template.html"}, ) self.assertEqual( load2.attributes, @@ -191,7 +196,8 @@ def test_file_template(self): }, ) self.assertEqual( - compile1.attributes, {"jinja2.template_name": "base.html"}, + compile1.attributes, + {"jinja2.template_name": "base.html"}, ) self.assertEqual( load1.attributes, @@ -201,7 +207,8 @@ def test_file_template(self): }, ) self.assertEqual( - render.attributes, {"jinja2.template_name": "template.html"}, + render.attributes, + {"jinja2.template_name": "template.html"}, ) def test_uninstrumented(self): diff --git a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py index a3fafb3d80..d88dffde2b 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py @@ -78,7 +78,7 @@ def _instrument(self, **kwargs): ) def _uninstrument(self, **kwargs): - """"Disable MySQL instrumentation""" + """ "Disable MySQL instrumentation""" dbapi.unwrap_connect(mysql.connector, "connect") # pylint:disable=no-self-use diff --git a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py index 830033bbe5..cc6f689613 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py +++ b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py @@ -142,7 +142,8 @@ def _get_span( return None task_name = properties.type if properties.type else task_name span = tracer.start_span( - name=_generate_span_name(destination, operation), kind=span_kind, + name=_generate_span_name(destination, operation), + kind=span_kind, ) if span.is_recording(): _enrich_span(span, channel, properties, task_name, operation) diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py index 4285fec1d0..e338902e1b 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py @@ -89,7 +89,7 @@ def _instrument(self, **kwargs): ) def _uninstrument(self, **kwargs): - """"Disable Psycopg2 instrumentation""" + """ "Disable Psycopg2 instrumentation""" dbapi.unwrap_connect(psycopg2, "connect") # TODO(owais): check if core dbapi can do this for all dbapi implementations e.g, pymysql and mysql diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py b/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py index 6e38c79cde..bb9a225467 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py @@ -37,7 +37,7 @@ class PymemcacheClientTestCase( TestBase ): # pylint: disable=too-many-public-methods - """ Tests for a patched pymemcache.client.base.Client. """ + """Tests for a patched pymemcache.client.base.Client.""" def setUp(self): super().setUp() @@ -470,7 +470,7 @@ def test_uninstrumented(self): class PymemcacheHashClientTestCase(TestBase): - """ Tests for a patched pymemcache.client.hash.HashClient. """ + """Tests for a patched pymemcache.client.hash.HashClient.""" def setUp(self): super().setUp() diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py index 1f3df6e76b..053e09140b 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py @@ -115,7 +115,7 @@ def __init__( self.failed_hook = failed_hook def started(self, event: monitoring.CommandStartedEvent): - """ Method to handle a pymongo CommandStartedEvent """ + """Method to handle a pymongo CommandStartedEvent""" if not self.is_enabled or context.get_value( _SUPPRESS_INSTRUMENTATION_KEY ): @@ -156,7 +156,7 @@ def started(self, event: monitoring.CommandStartedEvent): self._pop_span(event) def succeeded(self, event: monitoring.CommandSucceededEvent): - """ Method to handle a pymongo CommandSucceededEvent """ + """Method to handle a pymongo CommandSucceededEvent""" if not self.is_enabled or context.get_value( _SUPPRESS_INSTRUMENTATION_KEY ): @@ -172,7 +172,7 @@ def succeeded(self, event: monitoring.CommandSucceededEvent): span.end() def failed(self, event: monitoring.CommandFailedEvent): - """ Method to handle a pymongo CommandFailedEvent """ + """Method to handle a pymongo CommandFailedEvent""" if not self.is_enabled or context.get_value( _SUPPRESS_INSTRUMENTATION_KEY ): diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py b/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py index f51f58e6b3..ef3734c596 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py @@ -144,7 +144,8 @@ def test_failed(self): span = spans_list[0] self.assertIs( - span.status.status_code, trace_api.StatusCode.ERROR, + span.status.status_code, + trace_api.StatusCode.ERROR, ) self.assertEqual(span.status.description, "failure") self.assertIsNotNone(span.end_time) @@ -166,10 +167,12 @@ def test_multiple_commands(self): second_span = spans_list[1] self.assertIs( - first_span.status.status_code, trace_api.StatusCode.UNSET, + first_span.status.status_code, + trace_api.StatusCode.UNSET, ) self.assertIs( - second_span.status.status_code, trace_api.StatusCode.ERROR, + second_span.status.status_code, + trace_api.StatusCode.ERROR, ) def test_int_command(self): diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py index 0b524ec7f6..c48a5b6b3d 100644 --- a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py @@ -79,7 +79,7 @@ def _instrument(self, **kwargs): ) def _uninstrument(self, **kwargs): - """"Disable PyMySQL instrumentation""" + """ "Disable PyMySQL instrumentation""" dbapi.unwrap_connect(pymysql, "connect") @staticmethod diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/__init__.py b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/__init__.py index dd8e620baf..3cbf09573c 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/__init__.py @@ -153,7 +153,7 @@ def _instrument(self, **kwargs): _wrap("pyramid.config", "Configurator.__init__", _traced_init) def _uninstrument(self, **kwargs): - """"Disable Pyramid instrumentation""" + """ "Disable Pyramid instrumentation""" unwrap(Configurator, "__init__") @staticmethod diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py index 292c38e029..f8be4ca720 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py @@ -93,7 +93,9 @@ def _before_traversal(event): span_name = otel_wsgi.get_default_span_name(request_environ) span = tracer.start_span( - span_name, kind=trace.SpanKind.SERVER, start_time=start_time, + span_name, + kind=trace.SpanKind.SERVER, + start_time=start_time, ) if span.is_recording(): diff --git a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py index 29b15e3424..080b690099 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py @@ -167,7 +167,9 @@ def _traced_execute_pipeline(func, instance, args, kwargs): "redis", f"{redis_class}.execute_command", _traced_execute_command ) wrap_function_wrapper( - "redis.client", f"{pipeline_class}.execute", _traced_execute_pipeline, + "redis.client", + f"{pipeline_class}.execute", + _traced_execute_pipeline, ) wrap_function_wrapper( "redis.client", diff --git a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py index 523194080d..c5398b42f7 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py +++ b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py @@ -23,7 +23,7 @@ def _extract_conn_attributes(conn_kwargs): - """ Transform redis conn info into dict """ + """Transform redis conn info into dict""" attributes = { SpanAttributes.DB_SYSTEM: DbSystemValues.REDIS.value, } diff --git a/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py b/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py index b9ba03ec1b..878cc74310 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py +++ b/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py @@ -145,7 +145,9 @@ def name_callback(method, url): def test_excluded_urls_explicit(self): url_404 = "http://httpbin.org/status/404" httpretty.register_uri( - httpretty.GET, url_404, status=404, + httpretty.GET, + url_404, + status=404, ) RequestsInstrumentor().uninstrument() @@ -158,7 +160,9 @@ def test_excluded_urls_explicit(self): def test_excluded_urls_from_env(self): url = "http://localhost/env_excluded_arg/123" httpretty.register_uri( - httpretty.GET, url, status=200, + httpretty.GET, + url, + status=200, ) RequestsInstrumentor().uninstrument() @@ -183,7 +187,9 @@ def name_callback(method, url): def test_not_foundbasic(self): url_404 = "http://httpbin.org/status/404" httpretty.register_uri( - httpretty.GET, url_404, status=404, + httpretty.GET, + url_404, + status=404, ) result = self.perform_request(url_404) self.assertEqual(result.status_code, 404) @@ -195,7 +201,8 @@ def test_not_foundbasic(self): ) self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) def test_uninstrument(self): @@ -287,7 +294,8 @@ def span_callback(span, result: requests.Response): ) RequestsInstrumentor().instrument( - tracer_provider=self.tracer_provider, span_callback=span_callback, + tracer_provider=self.tracer_provider, + span_callback=span_callback, ) result = self.perform_request(self.URL) diff --git a/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/__init__.py b/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/__init__.py index 71ed1b6f0f..d38b373d18 100644 --- a/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-sklearn/src/opentelemetry/instrumentation/sklearn/__init__.py @@ -518,26 +518,36 @@ def _uninstrument_class_method( delegator = get_delegator(estimator, method_name) if self._check_instrumented(estimator, method_name): logger.debug( - "Uninstrumenting: %s.%s", qualname, method_name, + "Uninstrumenting: %s.%s", + qualname, + method_name, ) _, orig_method = getattr(estimator, orig_method_name) setattr( - estimator, method_name, orig_method, + estimator, + method_name, + orig_method, ) delattr(estimator, orig_method_name) elif delegator is not None: if not hasattr(delegator, "_otel_original_fn"): logger.debug( - "Already uninstrumented: %s.%s", qualname, method_name, + "Already uninstrumented: %s.%s", + qualname, + method_name, ) return setattr( - delegator, "fn", getattr(delegator, "_otel_original_fn"), + delegator, + "fn", + getattr(delegator, "_otel_original_fn"), ) delattr(delegator, "_otel_original_fn") else: logger.debug( - "Already uninstrumented: %s.%s", qualname, method_name, + "Already uninstrumented: %s.%s", + qualname, + method_name, ) def _uninstrument_instance_method( @@ -561,16 +571,22 @@ def _uninstrument_instance_method( qualname = estimator.__class__.__qualname__ if self._check_instrumented(estimator, method_name): logger.debug( - "Uninstrumenting: %s.%s", qualname, method_name, + "Uninstrumenting: %s.%s", + qualname, + method_name, ) _, orig_method = getattr(estimator, orig_method_name) setattr( - estimator, method_name, orig_method, + estimator, + method_name, + orig_method, ) delattr(estimator, orig_method_name) else: logger.debug( - "Already uninstrumented: %s.%s", qualname, method_name, + "Already uninstrumented: %s.%s", + qualname, + method_name, ) def _instrument_class_method( diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py index f516e54193..5af41b984f 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py @@ -132,7 +132,10 @@ def _handle_error(context): if span.is_recording(): span.set_status( - Status(StatusCode.ERROR, str(context.original_exception),) + Status( + StatusCode.ERROR, + str(context.original_exception), + ) ) span.end() diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py index c71f1ab8bd..ec3560f3d1 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py @@ -33,7 +33,8 @@ def tearDown(self): def test_trace_integration(self): engine = create_engine("sqlite:///:memory:") SQLAlchemyInstrumentor().instrument( - engine=engine, tracer_provider=self.tracer_provider, + engine=engine, + tracer_provider=self.tracer_provider, ) cnx = engine.connect() cnx.execute("SELECT 1 + 1;").fetchall() @@ -75,7 +76,8 @@ def test_not_recording(self): tracer.return_value = mock_tracer engine = create_engine("sqlite:///:memory:") SQLAlchemyInstrumentor().instrument( - engine=engine, tracer_provider=self.tracer_provider, + engine=engine, + tracer_provider=self.tracer_provider, ) cnx = engine.connect() cnx.execute("SELECT 1 + 1;").fetchall() diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py index 3464f3cc48..3620556118 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py @@ -74,7 +74,7 @@ def _instrument(self, **kwargs): ) def _uninstrument(self, **kwargs): - """"Disable SQLite3 instrumentation""" + """ "Disable SQLite3 instrumentation""" dbapi.unwrap_connect(sqlite3, "connect") @staticmethod diff --git a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/client.py b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/client.py index 04d5e22e93..03497ec5ca 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/client.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/client.py @@ -55,7 +55,9 @@ def fetch_async(tracer, request_hook, response_hook, func, _, args, kwargs): request = args[0] span = tracer.start_span( - request.method, kind=trace.SpanKind.CLIENT, start_time=start_time, + request.method, + kind=trace.SpanKind.CLIENT, + start_time=start_time, ) if request_hook: request_hook(span, request) diff --git a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py index 43e1997e61..636ce8d706 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py @@ -246,7 +246,9 @@ def _uninstrument_from(instr_root, restore_as_bound_func=False): instr_func_name = "open" instr_func = getattr(instr_root, instr_func_name) if not getattr( - instr_func, "opentelemetry_instrumentation_urllib_applied", False, + instr_func, + "opentelemetry_instrumentation_urllib_applied", + False, ): return diff --git a/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py b/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py index f037cc61bd..56b5068f2d 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py @@ -62,7 +62,9 @@ def setUp(self): body=self.base_exception_callback, ) httpretty.register_uri( - httpretty.GET, "http://httpbin.org/status/500", status=500, + httpretty.GET, + "http://httpbin.org/status/500", + status=500, ) # pylint: disable=invalid-name @@ -122,7 +124,9 @@ def test_basic(self): def test_not_foundbasic(self): url_404 = "http://httpbin.org/status/404/" httpretty.register_uri( - httpretty.GET, url_404, status=404, + httpretty.GET, + url_404, + status=404, ) exception = None try: @@ -139,7 +143,8 @@ def test_not_foundbasic(self): ) self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) def test_uninstrument(self): diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py index d2893d037b..f0b238b138 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/tests/test_urllib3_integration.py @@ -287,7 +287,9 @@ def request_hook(span, request, headers, body): span.set_attribute("request_hook_body", body) URLLib3Instrumentor().uninstrument() - URLLib3Instrumentor().instrument(request_hook=request_hook,) + URLLib3Instrumentor().instrument( + request_hook=request_hook, + ) headers = {"header1": "value1", "header2": "value2"} body = "param1=1¶m2=2" diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py index 2fbfbd304d..daaa519ba8 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py @@ -209,7 +209,8 @@ def test_wsgi_internal_error(self): span_list = self.memory_exporter.get_finished_spans() self.assertEqual(len(span_list), 1) self.assertEqual( - span_list[0].status.status_code, StatusCode.ERROR, + span_list[0].status.status_code, + StatusCode.ERROR, ) def test_default_span_name_missing_request_method(self): diff --git a/opentelemetry-instrumentation/setup.py b/opentelemetry-instrumentation/setup.py index b5cafbe667..9d1d5b7b06 100644 --- a/opentelemetry-instrumentation/setup.py +++ b/opentelemetry-instrumentation/setup.py @@ -24,4 +24,6 @@ with open(VERSION_FILENAME, encoding="utf-8") as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup(version=PACKAGE_INFO["__version__"],) +setuptools.setup( + version=PACKAGE_INFO["__version__"], +) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py index 334f612330..932022c24f 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py @@ -61,7 +61,8 @@ def run() -> None: argument = sub(r"OTEL_(PYTHON_)?", "", attribute).lower() parser.add_argument( - f"--{argument}", required=False, + f"--{argument}", + required=False, ) argument_otel_environment_variable[argument] = attribute diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/propagators.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/propagators.py index 168a7f7885..bc40f7742c 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/propagators.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/propagators.py @@ -118,5 +118,7 @@ def inject( f"00-{format_trace_id(span_context.trace_id)}-{format_span_id(span_context.span_id)}-{span_context.trace_flags:02x}", ) setter.set( - carrier, _HTTP_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS, header_name, + carrier, + _HTTP_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS, + header_name, ) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py index 7e10416410..f5a470d707 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py @@ -36,7 +36,9 @@ def extract_attributes_from_object( def http_status_to_status_code( - status: int, allow_redirect: bool = True, server_span: bool = False, + status: int, + allow_redirect: bool = True, + server_span: bool = False, ) -> StatusCode: """Converts an HTTP status code to an OpenTelemetry canonical status code diff --git a/opentelemetry-instrumentation/tests/test_bootstrap.py b/opentelemetry-instrumentation/tests/test_bootstrap.py index d1052de289..a266bf8a43 100644 --- a/opentelemetry-instrumentation/tests/test_bootstrap.py +++ b/opentelemetry-instrumentation/tests/test_bootstrap.py @@ -23,7 +23,10 @@ def sample_packages(packages, rate): - return sample(list(packages), int(len(packages) * rate),) + return sample( + list(packages), + int(len(packages) * rate), + ) class TestBootstrap(TestCase): @@ -74,13 +77,15 @@ def test_run_cmd_print(self): with patch("sys.stdout", new=StringIO()) as fake_out: bootstrap.run() self.assertEqual( - fake_out.getvalue(), "\n".join(self.installed_libraries), + fake_out.getvalue(), + "\n".join(self.installed_libraries), ) @patch("sys.argv", ["bootstrap", "-a", "install"]) def test_run_cmd_install(self): bootstrap.run() self.mock_pip_install.assert_has_calls( - [call(i) for i in self.installed_libraries], any_order=True, + [call(i) for i in self.installed_libraries], + any_order=True, ) self.assertEqual(self.mock_pip_check.call_count, 1) diff --git a/opentelemetry-instrumentation/tests/test_utils.py b/opentelemetry-instrumentation/tests/test_utils.py index 8679a43f78..7d751d0dc2 100644 --- a/opentelemetry-instrumentation/tests/test_utils.py +++ b/opentelemetry-instrumentation/tests/test_utils.py @@ -31,12 +31,24 @@ def test_http_status_to_status_code(self): (HTTPStatus.UNAUTHORIZED, StatusCode.ERROR), (HTTPStatus.FORBIDDEN, StatusCode.ERROR), (HTTPStatus.NOT_FOUND, StatusCode.ERROR), - (HTTPStatus.UNPROCESSABLE_ENTITY, StatusCode.ERROR,), - (HTTPStatus.TOO_MANY_REQUESTS, StatusCode.ERROR,), + ( + HTTPStatus.UNPROCESSABLE_ENTITY, + StatusCode.ERROR, + ), + ( + HTTPStatus.TOO_MANY_REQUESTS, + StatusCode.ERROR, + ), (HTTPStatus.NOT_IMPLEMENTED, StatusCode.ERROR), (HTTPStatus.SERVICE_UNAVAILABLE, StatusCode.ERROR), - (HTTPStatus.GATEWAY_TIMEOUT, StatusCode.ERROR,), - (HTTPStatus.HTTP_VERSION_NOT_SUPPORTED, StatusCode.ERROR,), + ( + HTTPStatus.GATEWAY_TIMEOUT, + StatusCode.ERROR, + ), + ( + HTTPStatus.HTTP_VERSION_NOT_SUPPORTED, + StatusCode.ERROR, + ), (600, StatusCode.ERROR), (99, StatusCode.ERROR), ): @@ -67,12 +79,24 @@ def test_http_status_to_status_code_server(self): (HTTPStatus.UNAUTHORIZED, StatusCode.UNSET), (HTTPStatus.FORBIDDEN, StatusCode.UNSET), (HTTPStatus.NOT_FOUND, StatusCode.UNSET), - (HTTPStatus.UNPROCESSABLE_ENTITY, StatusCode.UNSET,), - (HTTPStatus.TOO_MANY_REQUESTS, StatusCode.UNSET,), + ( + HTTPStatus.UNPROCESSABLE_ENTITY, + StatusCode.UNSET, + ), + ( + HTTPStatus.TOO_MANY_REQUESTS, + StatusCode.UNSET, + ), (HTTPStatus.NOT_IMPLEMENTED, StatusCode.ERROR), (HTTPStatus.SERVICE_UNAVAILABLE, StatusCode.ERROR), - (HTTPStatus.GATEWAY_TIMEOUT, StatusCode.ERROR,), - (HTTPStatus.HTTP_VERSION_NOT_SUPPORTED, StatusCode.ERROR,), + ( + HTTPStatus.GATEWAY_TIMEOUT, + StatusCode.ERROR, + ), + ( + HTTPStatus.HTTP_VERSION_NOT_SUPPORTED, + StatusCode.ERROR, + ), (600, StatusCode.ERROR), (99, StatusCode.ERROR), ): diff --git a/propagator/opentelemetry-propagator-aws-xray/src/opentelemetry/propagators/aws/aws_xray_propagator.py b/propagator/opentelemetry-propagator-aws-xray/src/opentelemetry/propagators/aws/aws_xray_propagator.py index 0a3dd8ee04..bd2ba95c7a 100644 --- a/propagator/opentelemetry-propagator-aws-xray/src/opentelemetry/propagators/aws/aws_xray_propagator.py +++ b/propagator/opentelemetry-propagator-aws-xray/src/opentelemetry/propagators/aws/aws_xray_propagator.py @@ -314,7 +314,9 @@ def inject( ) setter.set( - carrier, TRACE_HEADER_KEY, trace_header, + carrier, + TRACE_HEADER_KEY, + trace_header, ) @property diff --git a/propagator/opentelemetry-propagator-aws-xray/tests/test_aws_xray_propagator.py b/propagator/opentelemetry-propagator-aws-xray/tests/test_aws_xray_propagator.py index efc123b803..2fb8a4925c 100644 --- a/propagator/opentelemetry-propagator-aws-xray/tests/test_aws_xray_propagator.py +++ b/propagator/opentelemetry-propagator-aws-xray/tests/test_aws_xray_propagator.py @@ -81,7 +81,13 @@ def build_test_span_context( trace_flags=DEFAULT_TRACE_OPTIONS, trace_state=DEFAULT_TRACE_STATE, ): - return SpanContext(trace_id, span_id, is_remote, trace_flags, trace_state,) + return SpanContext( + trace_id, + span_id, + is_remote, + trace_flags, + trace_state, + ) class AwsXRayPropagatorTest(unittest.TestCase): @@ -93,7 +99,8 @@ def test_inject_into_non_sampled_context(self): carrier = CaseInsensitiveDict() AwsXRayPropagatorTest.XRAY_PROPAGATOR.inject( - carrier, build_test_current_context(), + carrier, + build_test_current_context(), ) injected_items = set(carrier.items()) @@ -154,7 +161,8 @@ def test_inject_reported_fields_matches_carrier_fields(self): carrier = CaseInsensitiveDict() AwsXRayPropagatorTest.XRAY_PROPAGATOR.inject( - carrier, build_test_current_context(), + carrier, + build_test_current_context(), ) injected_keys = set(carrier.keys()) diff --git a/propagator/opentelemetry-propagator-ot-trace/src/opentelemetry/propagators/ot_trace/__init__.py b/propagator/opentelemetry-propagator-ot-trace/src/opentelemetry/propagators/ot_trace/__init__.py index 6324cbf77e..ea47ae3f57 100644 --- a/propagator/opentelemetry-propagator-ot-trace/src/opentelemetry/propagators/ot_trace/__init__.py +++ b/propagator/opentelemetry-propagator-ot-trace/src/opentelemetry/propagators/ot_trace/__init__.py @@ -124,7 +124,9 @@ def inject( carrier, OT_TRACE_ID_HEADER, hex(span_context.trace_id)[2:][-16:] ) setter.set( - carrier, OT_SPAN_ID_HEADER, hex(span_context.span_id)[2:][-16:], + carrier, + OT_SPAN_ID_HEADER, + hex(span_context.span_id)[2:][-16:], ) if span_context.trace_flags == TraceFlags.SAMPLED: @@ -168,7 +170,8 @@ def fields(self): def _extract_first_element( - items: Iterable[CarrierT], default: Any = None, + items: Iterable[CarrierT], + default: Any = None, ) -> Optional[CarrierT]: if items is None: return default diff --git a/propagator/opentelemetry-propagator-ot-trace/tests/test_ot_trace_propagator.py b/propagator/opentelemetry-propagator-ot-trace/tests/test_ot_trace_propagator.py index 58bd4fa0ab..084497273a 100644 --- a/propagator/opentelemetry-propagator-ot-trace/tests/test_ot_trace_propagator.py +++ b/propagator/opentelemetry-propagator-ot-trace/tests/test_ot_trace_propagator.py @@ -60,7 +60,10 @@ def carrier_inject(self, trace_id, span_id, is_remote, trace_flags): def test_inject_short_trace_id_short_span_id(self): carrier = self.carrier_inject( - int("1", 16), int("2", 16), True, TraceFlags.SAMPLED, + int("1", 16), + int("2", 16), + True, + TraceFlags.SAMPLED, ) self.assertEqual(carrier[OT_TRACE_ID_HEADER], "1") diff --git a/pyproject.toml b/pyproject.toml index 83cac688f2..c1a64c5240 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,10 @@ line-length = 79 exclude = ''' ( - /( - )/ + \.git + | \.tox + | venv + | build + | dist ) ''' diff --git a/scripts/generate_instrumentation_readme.py b/scripts/generate_instrumentation_readme.py index dd8f1bb4bb..dbaa42367c 100755 --- a/scripts/generate_instrumentation_readme.py +++ b/scripts/generate_instrumentation_readme.py @@ -53,7 +53,11 @@ def main(): name = src_pkgs[0] pkg_info = {} - version_filename = os.path.join(src_dir, name, "package.py",) + version_filename = os.path.join( + src_dir, + name, + "package.py", + ) with open(version_filename, encoding="utf-8") as fh: exec(fh.read(), pkg_info) diff --git a/scripts/otel_packaging.py b/scripts/otel_packaging.py index f6f43fd689..ef0d114fee 100644 --- a/scripts/otel_packaging.py +++ b/scripts/otel_packaging.py @@ -35,7 +35,10 @@ def get_instrumentation_packages(): ) instrumentation = json.loads(out.splitlines()[1]) instrumentation["requirement"] = "==".join( - (instrumentation["name"], instrumentation["version"],) + ( + instrumentation["name"], + instrumentation["version"], + ) ) yield instrumentation diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/tests/resource/test_ecs.py b/sdk-extension/opentelemetry-sdk-extension-aws/tests/resource/test_ecs.py index 5e1aeea904..04931e1b76 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/tests/resource/test_ecs.py +++ b/sdk-extension/opentelemetry-sdk-extension-aws/tests/resource/test_ecs.py @@ -33,7 +33,9 @@ class AwsEcsResourceDetectorTest(unittest.TestCase): @patch.dict( - "os.environ", {"ECS_CONTAINER_METADATA_URI": "mock-uri"}, clear=True, + "os.environ", + {"ECS_CONTAINER_METADATA_URI": "mock-uri"}, + clear=True, ) @patch( "socket.gethostname", diff --git a/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mssql.py b/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mssql.py index bb49f55518..e3a1aae2ef 100644 --- a/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mssql.py +++ b/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mssql.py @@ -84,7 +84,8 @@ def test_engine_execute_errors(self): self.assertTrue(span.end_time - span.start_time > 0) # check the error self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) self.assertIn("a_wrong_table", span.status.description) diff --git a/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mysql.py b/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mysql.py index e31f992ff8..69b3c26286 100644 --- a/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mysql.py +++ b/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mysql.py @@ -83,6 +83,7 @@ def test_engine_execute_errors(self): self.assertTrue(span.end_time - span.start_time > 0) # check the error self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) self.assertIn("a_wrong_table", span.status.description) diff --git a/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_postgres.py b/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_postgres.py index 610f604e13..2893a5fd19 100644 --- a/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_postgres.py +++ b/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_postgres.py @@ -77,7 +77,8 @@ def test_engine_execute_errors(self): self.assertTrue(span.end_time - span.start_time > 0) # check the error self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) self.assertIn("a_wrong_table", span.status.description) diff --git a/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_sqlite.py b/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_sqlite.py index 821f25669d..2197028266 100644 --- a/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_sqlite.py +++ b/tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_sqlite.py @@ -52,7 +52,8 @@ def test_engine_execute_errors(self): self.assertTrue((span.end_time - span.start_time) > 0) # check the error self.assertIs( - span.status.status_code, trace.StatusCode.ERROR, + span.status.status_code, + trace.StatusCode.ERROR, ) self.assertEqual( span.status.description, "no such table: a_wrong_table" diff --git a/util/opentelemetry-util-http/src/opentelemetry/util/http/httplib.py b/util/opentelemetry-util-http/src/opentelemetry/util/http/httplib.py index b4aac01124..de95a0aa92 100644 --- a/util/opentelemetry-util-http/src/opentelemetry/util/http/httplib.py +++ b/util/opentelemetry-util-http/src/opentelemetry/util/http/httplib.py @@ -121,7 +121,9 @@ def instrument_connect(module, name="connect"): """Instrument additional connect() methods, e.g. for derived classes.""" wrapt.wrap_function_wrapper( - module, name, _instrumented_connect, + module, + name, + _instrumented_connect, ) @@ -136,7 +138,9 @@ def instrumented_send( return result wrapt.wrap_function_wrapper( - http.client.HTTPConnection, "send", instrumented_send, + http.client.HTTPConnection, + "send", + instrumented_send, ) instrument_connect(http.client.HTTPConnection)