From 1cd8ccb28a1823ab7dfc81d21c5e5c71f9f0eb7b Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Tue, 23 Apr 2024 17:15:22 +0200 Subject: [PATCH 1/2] CHANGELOG: deduplicate unreleased entries (#2451) --- CHANGELOG.md | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed7658fe87..4cbc913346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,16 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased -- Use sqlalchemy version in sqlalchemy commenter instead of opentelemetry library version - ([#2404](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2404)) - -### Added - -- `opentelemetry-instrumentation-pika` Instrumentation for `channel.consume()` (supported - only for global, non channel specific instrumentation) - ([#2397](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2397))) - - ### Breaking changes - Rename `type` attribute to `asgi.event.type` in `opentelemetry-instrumentation-asgi` @@ -35,6 +25,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#2425](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2425)) - `opentelemetry-instrumentation-threading` Initial release for threading ([#2253](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2253)) +- `opentelemetry-instrumentation-pika` Instrumentation for `channel.consume()` (supported + only for global, non channel specific instrumentation) + ([#2397](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2397))) ### Fixed @@ -42,15 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#2363](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2363)) - `opentelemetry-instrumentation-boto3sqs` Instrument Session and resource ([#2161](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2161)) - -### Added - -- `opentelemetry-sdk-extension-aws` Register AWS resource detectors under the `opentelemetry_resource_detector` entry point - ([#2382](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2382)) -- `opentelemetry-instrumentation-wsgi` Implement new semantic convention opt-in with stable http semantic conventions - ([#2425](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2425)) -- `opentelemetry-instrumentation-threading` Initial release for threading - ([#2253](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2253)) +- Use sqlalchemy version in sqlalchemy commenter instead of opentelemetry library version + ([#2404](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2404)) ## Version 1.24.0/0.45b0 (2024-03-28) From a0c3211c4fd3326279740480c0c1938a17a125c8 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Tue, 23 Apr 2024 17:45:48 +0200 Subject: [PATCH 2/2] Bump black to 24.3.0 (#2452) --- .flake8 | 4 +++ dev-requirements.txt | 2 +- .../prometheus_remote_write/gen/remote_pb2.py | 12 +++---- .../prometheus_remote_write/gen/types_pb2.py | 36 +++++++++---------- .../instrumentation/asgi/__init__.py | 6 ++-- .../instrumentation/asyncpg/__init__.py | 12 +++---- .../botocore/extensions/lmbd.py | 6 ++-- .../botocore/extensions/sns.py | 6 ++-- .../botocore/extensions/sqs.py | 6 ++-- .../django/middleware/otel_middleware.py | 18 +++++----- .../middleware/sqlcommenter_middleware.py | 24 ++++++++----- .../tests/test_middleware.py | 8 +++-- .../tests/views.py | 12 +++---- .../instrumentation/elasticsearch/__init__.py | 6 ++-- .../instrumentation/falcon/__init__.py | 6 ++-- .../instrumentation/flask/__init__.py | 12 +++---- .../tests/base_test.py | 18 +++++----- .../tests/protobuf/test_server_pb2.py | 4 +-- .../instrumentation/httpx/__init__.py | 4 +-- .../instrumentation/pika/pika_instrumentor.py | 6 ++-- .../instrumentation/pika/utils.py | 17 ++++----- .../instrumentation/pymemcache/__init__.py | 12 +++---- .../instrumentation/pymongo/__init__.py | 3 +- .../instrumentation/pyramid/callbacks.py | 12 +++---- .../instrumentation/redis/util.py | 12 +++---- .../instrumentation/requests/__init__.py | 20 ++++++----- .../instrumentation/sqlalchemy/engine.py | 12 +++---- .../system_metrics/__init__.py | 20 ++++++----- .../instrumentation/tornado/__init__.py | 6 ++-- .../instrumentation/tortoiseorm/__init__.py | 18 +++++----- .../instrumentation/urllib/__init__.py | 14 ++++---- .../instrumentation/urllib3/__init__.py | 8 +++-- .../tests/test_wsgi_middleware.py | 18 +++++----- .../opentelemetry/instrumentation/_semconv.py | 12 +++---- .../propagators/ot_trace/__init__.py | 6 ++-- .../resource/detector/azure/app_service.py | 20 +++++------ scripts/check_for_valid_readme.py | 1 + 37 files changed, 219 insertions(+), 200 deletions(-) diff --git a/.flake8 b/.flake8 index 8b2144c00f..5683cfc1f3 100644 --- a/.flake8 +++ b/.flake8 @@ -12,6 +12,10 @@ ignore = # allow whitespace before ':' (https://github.com/psf/black#slices) E203 + # conflicts with black + E701 + E704 + exclude = .bzr .git diff --git a/dev-requirements.txt b/dev-requirements.txt index fffb4c445d..1c49c57b7e 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ pylint==3.0.2 flake8==6.1.0 isort==5.12.0 -black==22.3.0 +black==24.3.0 httpretty==1.1.4 mypy==0.931 sphinx==7.1.2 diff --git a/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/gen/remote_pb2.py b/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/gen/remote_pb2.py index 3efcb36536..f8724074f6 100644 --- a/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/gen/remote_pb2.py +++ b/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/gen/remote_pb2.py @@ -34,13 +34,13 @@ DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"Z\006prompb" _WRITEREQUEST.fields_by_name["timeseries"]._options = None - _WRITEREQUEST.fields_by_name[ - "timeseries" - ]._serialized_options = b"\310\336\037\000" + _WRITEREQUEST.fields_by_name["timeseries"]._serialized_options = ( + b"\310\336\037\000" + ) _WRITEREQUEST.fields_by_name["metadata"]._options = None - _WRITEREQUEST.fields_by_name[ - "metadata" - ]._serialized_options = b"\310\336\037\000" + _WRITEREQUEST.fields_by_name["metadata"]._serialized_options = ( + b"\310\336\037\000" + ) _WRITEREQUEST._serialized_start = 216 _WRITEREQUEST._serialized_end = 338 _READREQUEST._serialized_start = 341 diff --git a/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/gen/types_pb2.py b/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/gen/types_pb2.py index fbfa2123ad..30cf2e38cc 100644 --- a/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/gen/types_pb2.py +++ b/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/gen/types_pb2.py @@ -31,31 +31,31 @@ DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"Z\006prompb" _EXEMPLAR.fields_by_name["labels"]._options = None - _EXEMPLAR.fields_by_name[ - "labels" - ]._serialized_options = b"\310\336\037\000" + _EXEMPLAR.fields_by_name["labels"]._serialized_options = ( + b"\310\336\037\000" + ) _TIMESERIES.fields_by_name["labels"]._options = None - _TIMESERIES.fields_by_name[ - "labels" - ]._serialized_options = b"\310\336\037\000" + _TIMESERIES.fields_by_name["labels"]._serialized_options = ( + b"\310\336\037\000" + ) _TIMESERIES.fields_by_name["samples"]._options = None - _TIMESERIES.fields_by_name[ - "samples" - ]._serialized_options = b"\310\336\037\000" + _TIMESERIES.fields_by_name["samples"]._serialized_options = ( + b"\310\336\037\000" + ) _TIMESERIES.fields_by_name["exemplars"]._options = None - _TIMESERIES.fields_by_name[ - "exemplars" - ]._serialized_options = b"\310\336\037\000" + _TIMESERIES.fields_by_name["exemplars"]._serialized_options = ( + b"\310\336\037\000" + ) _LABELS.fields_by_name["labels"]._options = None _LABELS.fields_by_name["labels"]._serialized_options = b"\310\336\037\000" _CHUNKEDSERIES.fields_by_name["labels"]._options = None - _CHUNKEDSERIES.fields_by_name[ - "labels" - ]._serialized_options = b"\310\336\037\000" + _CHUNKEDSERIES.fields_by_name["labels"]._serialized_options = ( + b"\310\336\037\000" + ) _CHUNKEDSERIES.fields_by_name["chunks"]._options = None - _CHUNKEDSERIES.fields_by_name[ - "chunks" - ]._serialized_options = b"\310\336\037\000" + _CHUNKEDSERIES.fields_by_name["chunks"]._serialized_options = ( + b"\310\336\037\000" + ) _METRICMETADATA._serialized_start = 152 _METRICMETADATA._serialized_end = 400 _METRICMETADATA_METRICTYPE._serialized_start = 279 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 8e4d699cbb..405c470ceb 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -695,9 +695,9 @@ async def otel_send(message: dict[str, Any]): if send_span.is_recording(): if message["type"] == "http.response.start": status_code = message["status"] - duration_attrs[ - SpanAttributes.HTTP_STATUS_CODE - ] = status_code + duration_attrs[SpanAttributes.HTTP_STATUS_CODE] = ( + status_code + ) set_status_code(server_span, status_code) set_status_code(send_span, status_code) diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py index 11c579f96a..798a5dc00b 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py @@ -77,14 +77,14 @@ def _hydrate_span_from_args(connection, query, parameters) -> dict: if isinstance(addr, tuple): span_attributes[SpanAttributes.NET_PEER_NAME] = addr[0] span_attributes[SpanAttributes.NET_PEER_PORT] = addr[1] - span_attributes[ - SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.IP_TCP.value + span_attributes[SpanAttributes.NET_TRANSPORT] = ( + NetTransportValues.IP_TCP.value + ) elif isinstance(addr, str): span_attributes[SpanAttributes.NET_PEER_NAME] = addr - span_attributes[ - SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.OTHER.value + span_attributes[SpanAttributes.NET_TRANSPORT] = ( + NetTransportValues.OTHER.value + ) if query is not None: span_attributes[SpanAttributes.DB_STATEMENT] = query diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/lmbd.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/lmbd.py index 299a37ab6c..57fb8b6794 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/lmbd.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/lmbd.py @@ -62,9 +62,9 @@ def extract_attributes( cls, call_context: _AwsSdkCallContext, attributes: _AttributeMapT ): attributes[SpanAttributes.FAAS_INVOKED_PROVIDER] = "aws" - attributes[ - SpanAttributes.FAAS_INVOKED_NAME - ] = cls._parse_function_name(call_context) + attributes[SpanAttributes.FAAS_INVOKED_NAME] = ( + cls._parse_function_name(call_context) + ) attributes[SpanAttributes.FAAS_INVOKED_REGION] = call_context.region @classmethod diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py index aa55ae697f..9c3df3a2bc 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py @@ -76,9 +76,9 @@ def extract_attributes( destination_name, is_phone_number = cls._extract_destination_name( call_context ) - attributes[ - SpanAttributes.MESSAGING_DESTINATION_KIND - ] = MessagingDestinationKindValues.TOPIC.value + attributes[SpanAttributes.MESSAGING_DESTINATION_KIND] = ( + MessagingDestinationKindValues.TOPIC.value + ) attributes[SpanAttributes.MESSAGING_DESTINATION] = destination_name # TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when opentelemetry-semantic-conventions 0.42b0 is released diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sqs.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sqs.py index 777108cbb5..194e47b57f 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sqs.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sqs.py @@ -35,9 +35,9 @@ def extract_attributes(self, attributes: _AttributeMapT): attributes[SpanAttributes.MESSAGING_SYSTEM] = "aws.sqs" attributes[SpanAttributes.MESSAGING_URL] = queue_url try: - attributes[ - SpanAttributes.MESSAGING_DESTINATION - ] = queue_url.split("/")[-1] + attributes[SpanAttributes.MESSAGING_DESTINATION] = ( + queue_url.split("/")[-1] + ) except IndexError: _logger.error( "Could not extract messaging destination from '%s'", diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/otel_middleware.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/otel_middleware.py index bc677a81cf..1b747fd2c0 100644 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/otel_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/otel_middleware.py @@ -163,9 +163,9 @@ class _DjangoMiddleware(MiddlewareMixin): _active_request_counter = None _otel_request_hook: Callable[[Span, HttpRequest], None] = None - _otel_response_hook: Callable[ - [Span, HttpRequest, HttpResponse], None - ] = None + _otel_response_hook: Callable[[Span, HttpRequest, HttpResponse], None] = ( + None + ) @staticmethod def _get_span_name(request): @@ -229,9 +229,9 @@ def process_request(self, request): ) duration_attrs = _parse_duration_attrs(attributes) - request.META[ - self._environ_active_request_attr_key - ] = active_requests_count_attrs + request.META[self._environ_active_request_attr_key] = ( + active_requests_count_attrs + ) request.META[self._environ_duration_attr_key] = duration_attrs self._active_request_counter.add(1, active_requests_count_attrs) if span.is_recording(): @@ -336,9 +336,9 @@ def process_response(self, request, response): self._environ_duration_attr_key, None ) if duration_attrs: - duration_attrs[ - SpanAttributes.HTTP_STATUS_CODE - ] = response.status_code + duration_attrs[SpanAttributes.HTTP_STATUS_CODE] = ( + response.status_code + ) request_start_time = request.META.pop(self._environ_timer_key, None) if activation and span: diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py index 30492a8be5..ef53d5dc38 100644 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py @@ -83,20 +83,26 @@ def __call__(self, execute: Type[T], sql, params, many, context) -> T: sql = _add_sql_comment( sql, # Information about the controller. - controller=resolver_match.view_name - if resolver_match and with_controller - else None, + controller=( + resolver_match.view_name + if resolver_match and with_controller + else None + ), # route is the pattern that matched a request with a controller i.e. the regex # See https://docs.djangoproject.com/en/stable/ref/urlresolvers/#django.urls.ResolverMatch.route # getattr() because the attribute doesn't exist in Django < 2.2. - route=getattr(resolver_match, "route", None) - if resolver_match and with_route - else None, + route=( + getattr(resolver_match, "route", None) + if resolver_match and with_route + else None + ), # app_name is the application namespace for the URL pattern that matches the URL. # See https://docs.djangoproject.com/en/stable/ref/urlresolvers/#django.urls.ResolverMatch.app_name - app_name=(resolver_match.app_name or None) - if resolver_match and with_app_name - else None, + app_name=( + (resolver_match.app_name or None) + if resolver_match and with_app_name + else None + ), # Framework centric information. framework=f"django:{_django_version}" if with_framework else None, # Information about the database and driver. diff --git a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py index 4d221fae62..63af1e6b86 100644 --- a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py @@ -155,9 +155,11 @@ def test_templated_route_get(self): self.assertEqual( span.name, - "GET ^route/(?P[0-9]{4})/template/$" - if DJANGO_2_2 - else "GET", + ( + "GET ^route/(?P[0-9]{4})/template/$" + if DJANGO_2_2 + else "GET" + ), ) self.assertEqual(span.kind, SpanKind.SERVER) self.assertEqual(span.status.status_code, StatusCode.UNSET) diff --git a/instrumentation/opentelemetry-instrumentation-django/tests/views.py b/instrumentation/opentelemetry-instrumentation-django/tests/views.py index 452a7c0fdd..6310664100 100644 --- a/instrumentation/opentelemetry-instrumentation-django/tests/views.py +++ b/instrumentation/opentelemetry-instrumentation-django/tests/views.py @@ -35,12 +35,12 @@ def response_with_custom_header(request): response = HttpResponse() response["custom-test-header-1"] = "test-header-value-1" response["custom-test-header-2"] = "test-header-value-2" - response[ - "my-custom-regex-header-1" - ] = "my-custom-regex-value-1,my-custom-regex-value-2" - response[ - "my-custom-regex-header-2" - ] = "my-custom-regex-value-3,my-custom-regex-value-4" + response["my-custom-regex-header-1"] = ( + "my-custom-regex-value-1,my-custom-regex-value-2" + ) + response["my-custom-regex-header-2"] = ( + "my-custom-regex-value-3,my-custom-regex-value-4" + ) response["my-secret-header"] = "my-secret-value" return response 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 0f5056de83..ceb50cac56 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py @@ -247,9 +247,9 @@ def wrapper(wrapped, _, args, kwargs): if body: # Don't set db.statement for bulk requests, as it can be very large if isinstance(body, dict): - attributes[ - SpanAttributes.DB_STATEMENT - ] = sanitize_body(body) + attributes[SpanAttributes.DB_STATEMENT] = ( + sanitize_body(body) + ) if params: attributes["elasticsearch.params"] = str(params) if doc_id: 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 06a550cf3f..79c9a0cf0f 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py @@ -382,9 +382,9 @@ def _start_response(status, response_headers, *args, **kwargs): raise finally: if span.is_recording(): - duration_attrs[ - SpanAttributes.HTTP_STATUS_CODE - ] = span.attributes.get(SpanAttributes.HTTP_STATUS_CODE) + duration_attrs[SpanAttributes.HTTP_STATUS_CODE] = ( + span.attributes.get(SpanAttributes.HTTP_STATUS_CODE) + ) duration = max(round((default_timer() - start) * 1000), 0) self.duration_histogram.record(duration, duration_attrs) self.active_requests_counter.add(-1, active_requests_count_attrs) 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 ba1031655e..a17f83a877 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py @@ -334,9 +334,9 @@ def _start_response(status, response_headers, *args, **kwargs): ) status_code = otel_wsgi._parse_status_code(status) if status_code is not None: - duration_attrs[ - SpanAttributes.HTTP_STATUS_CODE - ] = status_code + duration_attrs[SpanAttributes.HTTP_STATUS_CODE] = ( + status_code + ) if ( span.is_recording() and span.kind == trace.SpanKind.SERVER @@ -641,9 +641,9 @@ def instrument_app( tracer, excluded_urls=excluded_urls, enable_commenter=enable_commenter, - commenter_options=commenter_options - if commenter_options - else {}, + commenter_options=( + commenter_options if commenter_options else {} + ), ) app._before_request = _before_request app.before_request(_before_request) diff --git a/instrumentation/opentelemetry-instrumentation-flask/tests/base_test.py b/instrumentation/opentelemetry-instrumentation-flask/tests/base_test.py index 3c8073f261..307ac3ccf0 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/tests/base_test.py +++ b/instrumentation/opentelemetry-instrumentation-flask/tests/base_test.py @@ -76,15 +76,15 @@ def _custom_response_headers(): resp = flask.Response("test response") resp.headers["content-type"] = "text/plain; charset=utf-8" resp.headers["content-length"] = "13" - resp.headers[ - "my-custom-header" - ] = "my-custom-value-1,my-custom-header-2" - resp.headers[ - "my-custom-regex-header-1" - ] = "my-custom-regex-value-1,my-custom-regex-value-2" - resp.headers[ - "My-Custom-Regex-Header-2" - ] = "my-custom-regex-value-3,my-custom-regex-value-4" + resp.headers["my-custom-header"] = ( + "my-custom-value-1,my-custom-header-2" + ) + resp.headers["my-custom-regex-header-1"] = ( + "my-custom-regex-value-1,my-custom-regex-value-2" + ) + resp.headers["My-Custom-Regex-Header-2"] = ( + "my-custom-regex-value-3,my-custom-regex-value-4" + ) resp.headers["my-secret-header"] = "my-secret-value" return resp diff --git a/instrumentation/opentelemetry-instrumentation-grpc/tests/protobuf/test_server_pb2.py b/instrumentation/opentelemetry-instrumentation-grpc/tests/protobuf/test_server_pb2.py index ad3dcf3fe7..f00b5f82e7 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/tests/protobuf/test_server_pb2.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/tests/protobuf/test_server_pb2.py @@ -142,7 +142,7 @@ (_message.Message,), { "DESCRIPTOR": _REQUEST, - "__module__": "test_server_pb2" + "__module__": "test_server_pb2", # @@protoc_insertion_point(class_scope:Request) }, ) @@ -153,7 +153,7 @@ (_message.Message,), { "DESCRIPTOR": _RESPONSE, - "__module__": "test_server_pb2" + "__module__": "test_server_pb2", # @@protoc_insertion_point(class_scope:Response) }, ) diff --git a/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py b/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py index e6609157c4..7fcc7128be 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py @@ -433,9 +433,7 @@ async def __aexit__( ) -> None: await self._transport.__aexit__(exc_type, exc_value, traceback) - async def handle_async_request( - self, *args, **kwargs - ) -> typing.Union[ + async def handle_async_request(self, *args, **kwargs) -> typing.Union[ typing.Tuple[int, "Headers", httpx.AsyncByteStream, dict], httpx.Response, ]: diff --git a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/pika_instrumentor.py b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/pika_instrumentor.py index 76261c89ce..f37f74e396 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/pika_instrumentor.py +++ b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/pika_instrumentor.py @@ -156,9 +156,9 @@ def uninstrument_channel(channel: BlockingChannel) -> None: callback_attr = PikaInstrumentor.CONSUMER_CALLBACK_ATTR consumer_callback = getattr(client_info, callback_attr, None) if hasattr(consumer_callback, "_original_callback"): - channel._consumer_infos[ - consumers_tag - ] = consumer_callback._original_callback + channel._consumer_infos[consumers_tag] = ( + consumer_callback._original_callback + ) PikaInstrumentor._uninstrument_channel_functions(channel) def _decorate_channel_function( 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 5afa5d9ee6..2b4d1204ea 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py +++ b/instrumentation/opentelemetry-instrumentation-pika/src/opentelemetry/instrumentation/pika/utils.py @@ -38,8 +38,7 @@ def keys(self, carrier: CarrierT) -> List[str]: HookT = Callable[[Span, bytes, BasicProperties], None] -def dummy_callback(span: Span, body: bytes, properties: BasicProperties): - ... +def dummy_callback(span: Span, body: bytes, properties: BasicProperties): ... def _decorate_callback( @@ -66,9 +65,9 @@ def decorated_callback( tracer, channel, properties, - destination=method.exchange - if method.exchange - else method.routing_key, + destination=( + method.exchange if method.exchange else method.routing_key + ), span_kind=SpanKind.CONSUMER, task_name=task_name, operation=MessagingOperationValues.RECEIVE, @@ -243,9 +242,11 @@ def popleft(self, *args, **kwargs): self._self_tracer, None, properties, - destination=method.exchange - if method.exchange - else method.routing_key, + destination=( + method.exchange + if method.exchange + else method.routing_key + ), span_kind=SpanKind.CONSUMER, task_name=self._self_queue_consumer_generator.consumer_tag, operation=MessagingOperationValues.RECEIVE, diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py index 512ce9ea56..d763734aca 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py @@ -162,14 +162,14 @@ def _get_address_attributes(instance): host, port = instance.server address_attributes[SpanAttributes.NET_PEER_NAME] = host address_attributes[SpanAttributes.NET_PEER_PORT] = port - address_attributes[ - SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.IP_TCP.value + address_attributes[SpanAttributes.NET_TRANSPORT] = ( + NetTransportValues.IP_TCP.value + ) elif isinstance(instance.server, str): address_attributes[SpanAttributes.NET_PEER_NAME] = instance.server - address_attributes[ - SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.OTHER.value + address_attributes[SpanAttributes.NET_TRANSPORT] = ( + NetTransportValues.OTHER.value + ) return address_attributes 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 506669a5c6..f55aa2be33 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py @@ -98,8 +98,7 @@ def failed_hook(span, event): FailedHookT = Callable[[Span, monitoring.CommandFailedEvent], None] -def dummy_callback(span, event): - ... +def dummy_callback(span, event): ... class CommandTracer(monitoring.CommandListener): 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 4f17da3da5..ede3e09608 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py @@ -106,9 +106,9 @@ def _before_traversal(event): if span.is_recording(): attributes = otel_wsgi.collect_request_attributes(request_environ) if request.matched_route: - attributes[ - SpanAttributes.HTTP_ROUTE - ] = request.matched_route.pattern + attributes[SpanAttributes.HTTP_ROUTE] = ( + request.matched_route.pattern + ) for key, value in attributes.items(): span.set_attribute(key, value) if span.kind == trace.SpanKind.SERVER: @@ -201,9 +201,9 @@ def trace_tween(request): status = getattr(response, "status", status) status_code = otel_wsgi._parse_status_code(status) if status_code is not None: - duration_attrs[ - SpanAttributes.HTTP_STATUS_CODE - ] = otel_wsgi._parse_status_code(status) + duration_attrs[SpanAttributes.HTTP_STATUS_CODE] = ( + otel_wsgi._parse_status_code(status) + ) duration_histogram.record(duration, duration_attrs) active_requests_counter.add(-1, active_requests_count_attrs) span = request.environ.get(_ENVIRON_SPAN_KEY) 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 3c274c8c43..2a24ead79a 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py +++ b/instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py @@ -36,14 +36,14 @@ def _extract_conn_attributes(conn_kwargs): attributes[SpanAttributes.NET_PEER_PORT] = conn_kwargs.get( "port", 6379 ) - attributes[ - SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.IP_TCP.value + attributes[SpanAttributes.NET_TRANSPORT] = ( + NetTransportValues.IP_TCP.value + ) except KeyError: attributes[SpanAttributes.NET_PEER_NAME] = conn_kwargs.get("path", "") - attributes[ - SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.OTHER.value + attributes[SpanAttributes.NET_TRANSPORT] = ( + NetTransportValues.OTHER.value + ) return attributes diff --git a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py index 2052fe47cd..f468ff87ff 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py @@ -189,9 +189,9 @@ def get_or_create_headers(): sem_conv_opt_in_mode, ) # Use semconv library when available - span_attributes[ - _SPAN_ATTRIBUTES_NETWORK_PEER_ADDRESS - ] = parsed_url.hostname + span_attributes[_SPAN_ATTRIBUTES_NETWORK_PEER_ADDRESS] = ( + parsed_url.hostname + ) if parsed_url.port: _set_http_peer_port_client( metric_labels, parsed_url.port, sem_conv_opt_in_mode @@ -201,9 +201,9 @@ def get_or_create_headers(): span_attributes, parsed_url.port, sem_conv_opt_in_mode ) # Use semconv library when available - span_attributes[ - _SPAN_ATTRIBUTES_NETWORK_PEER_PORT - ] = parsed_url.port + span_attributes[_SPAN_ATTRIBUTES_NETWORK_PEER_PORT] = ( + parsed_url.port + ) except ValueError: pass @@ -413,9 +413,11 @@ def _instrument(self, **kwargs): duration_histogram_new, request_hook=kwargs.get("request_hook"), response_hook=kwargs.get("response_hook"), - excluded_urls=_excluded_urls_from_env - if excluded_urls is None - else parse_excluded_urls(excluded_urls), + excluded_urls=( + _excluded_urls_from_env + if excluded_urls is None + else parse_excluded_urls(excluded_urls) + ), sem_conv_opt_in_mode=semconv_opt_in_mode, ) 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 a810aedc38..172c1193f3 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py @@ -296,18 +296,18 @@ def _get_attributes_from_cursor(vendor, cursor, attrs): is_unix_socket = info.host and info.host.startswith("/") if is_unix_socket: - attrs[ - SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.OTHER.value + attrs[SpanAttributes.NET_TRANSPORT] = ( + NetTransportValues.OTHER.value + ) if info.port: # postgresql enforces this pattern on all socket names attrs[SpanAttributes.NET_PEER_NAME] = os.path.join( info.host, f".s.PGSQL.{info.port}" ) else: - attrs[ - SpanAttributes.NET_TRANSPORT - ] = NetTransportValues.IP_TCP.value + attrs[SpanAttributes.NET_TRANSPORT] = ( + NetTransportValues.IP_TCP.value + ) attrs[SpanAttributes.NET_PEER_NAME] = info.host if info.port: attrs[SpanAttributes.NET_PEER_PORT] = int(info.port) diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py index 32766fa0c5..74d4f6a431 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py @@ -481,9 +481,11 @@ def _get_system_swap_utilization( if hasattr(system_swap, metric): self._system_swap_utilization_labels["state"] = metric yield Observation( - getattr(system_swap, metric) / system_swap.total - if system_swap.total - else 0, + ( + getattr(system_swap, metric) / system_swap.total + if system_swap.total + else 0 + ), self._system_swap_utilization_labels.copy(), ) @@ -556,9 +558,9 @@ def _get_system_network_dropped_packets( for metric in self._config["system.network.dropped.packets"]: in_out = {"receive": "in", "transmit": "out"}[metric] if hasattr(counters, f"drop{in_out}"): - self._system_network_dropped_packets_labels[ - "device" - ] = device + self._system_network_dropped_packets_labels["device"] = ( + device + ) self._system_network_dropped_packets_labels[ "direction" ] = metric @@ -629,9 +631,9 @@ def _get_system_network_connections( 1: "tcp", 2: "udp", }[net_connection.type.value] - self._system_network_connections_labels[ - "state" - ] = net_connection.status + self._system_network_connections_labels["state"] = ( + net_connection.status + ) self._system_network_connections_labels[metric] = getattr( net_connection, metric ) diff --git a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py index 5a39538837..5c99457a39 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py @@ -455,9 +455,9 @@ def _get_attributes_from_request(request): if hasattr(request.connection, "context") and getattr( request.connection.context, "_orig_remote_ip", None ): - attrs[ - SpanAttributes.NET_PEER_IP - ] = request.connection.context._orig_remote_ip + attrs[SpanAttributes.NET_PEER_IP] = ( + request.connection.context._orig_remote_ip + ) return extract_attributes_from_object( request, _traced_request_attrs, attrs diff --git a/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.py b/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.py index 7988daf130..cebcb81ced 100644 --- a/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.py @@ -229,17 +229,17 @@ def _hydrate_span_from_args(self, connection, query, parameters) -> dict: capabilities = getattr(connection, "capabilities", None) if capabilities is not None: if capabilities.dialect == "sqlite": - span_attributes[ - SpanAttributes.DB_SYSTEM - ] = DbSystemValues.SQLITE.value + span_attributes[SpanAttributes.DB_SYSTEM] = ( + DbSystemValues.SQLITE.value + ) elif capabilities.dialect == "postgres": - span_attributes[ - SpanAttributes.DB_SYSTEM - ] = DbSystemValues.POSTGRESQL.value + span_attributes[SpanAttributes.DB_SYSTEM] = ( + DbSystemValues.POSTGRESQL.value + ) elif capabilities.dialect == "mysql": - span_attributes[ - SpanAttributes.DB_SYSTEM - ] = DbSystemValues.MYSQL.value + span_attributes[SpanAttributes.DB_SYSTEM] = ( + DbSystemValues.MYSQL.value + ) dbname = getattr(connection, "filename", None) if dbname: span_attributes[SpanAttributes.DB_NAME] = dbname 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 3738c4d2c6..befc022b35 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py @@ -156,9 +156,11 @@ def _instrument(self, **kwargs): histograms, request_hook=kwargs.get("request_hook"), response_hook=kwargs.get("response_hook"), - excluded_urls=_excluded_urls_from_env - if excluded_urls is None - else parse_excluded_urls(excluded_urls), + excluded_urls=( + _excluded_urls_from_env + if excluded_urls is None + else parse_excluded_urls(excluded_urls) + ), ) def _uninstrument(self, **kwargs): @@ -251,9 +253,9 @@ def _instrumented_open_call( ver_ = str(getattr(result, "version", "")) if ver_: - labels[ - SpanAttributes.HTTP_FLAVOR - ] = f"{ver_[:1]}.{ver_[:-1]}" + labels[SpanAttributes.HTTP_FLAVOR] = ( + f"{ver_[:1]}.{ver_[:-1]}" + ) _record_histograms( histograms, labels, request, result, elapsed_time 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 985f291199..add5db8f19 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py @@ -200,9 +200,11 @@ def _instrument(self, **kwargs): request_hook=kwargs.get("request_hook"), response_hook=kwargs.get("response_hook"), url_filter=kwargs.get("url_filter"), - excluded_urls=_excluded_urls_from_env - if excluded_urls is None - else parse_excluded_urls(excluded_urls), + excluded_urls=( + _excluded_urls_from_env + if excluded_urls is None + else parse_excluded_urls(excluded_urls) + ), ) def _uninstrument(self, **kwargs): diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py index 985fbe0571..b55ac6808f 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py @@ -252,9 +252,9 @@ def validate_response( if old_sem_conv: expected_attributes[SpanAttributes.HTTP_METHOD] = http_method if new_sem_conv: - expected_attributes[ - SpanAttributes.HTTP_REQUEST_METHOD - ] = http_method + expected_attributes[SpanAttributes.HTTP_REQUEST_METHOD] = ( + http_method + ) self.assertEqual(span_list[0].attributes, expected_attributes) def test_basic_wsgi_call(self): @@ -562,9 +562,9 @@ def validate_url( parts.path, 1 )[1] if parts.query: - expected_new[ - SpanAttributes.URL_QUERY - ] = expected_url.split(parts.query, 1)[1] + expected_new[SpanAttributes.URL_QUERY] = ( + expected_url.split(parts.query, 1)[1] + ) else: expected_new[SpanAttributes.HTTP_URL] = expected_url if has_host: @@ -710,9 +710,9 @@ def test_request_attributes_pathless(self): def test_request_attributes_with_full_request_uri(self): self.environ["HTTP_HOST"] = "127.0.0.1:8080" self.environ["REQUEST_METHOD"] = "CONNECT" - self.environ[ - "REQUEST_URI" - ] = "http://docs.python.org:80/3/library/urllib.parse.html?highlight=params#url-parsing" # Might happen in a CONNECT request + self.environ["REQUEST_URI"] = ( + "http://docs.python.org:80/3/library/urllib.parse.html?highlight=params#url-parsing" # Might happen in a CONNECT request + ) expected_old = { SpanAttributes.HTTP_HOST: "127.0.0.1:8080", SpanAttributes.HTTP_TARGET: "http://docs.python.org:80/3/library/urllib.parse.html?highlight=params#url-parsing", diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py index 31c2486acc..8f236b5479 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py @@ -368,16 +368,16 @@ def _set_status( span.set_attribute( SpanAttributes.HTTP_RESPONSE_STATUS_CODE, status_code ) - metrics_attributes[ - SpanAttributes.HTTP_RESPONSE_STATUS_CODE - ] = status_code + metrics_attributes[SpanAttributes.HTTP_RESPONSE_STATUS_CODE] = ( + status_code + ) if status == StatusCode.ERROR: span.set_attribute( _SPAN_ATTRIBUTES_ERROR_TYPE, status_code_str ) - metrics_attributes[ - _SPAN_ATTRIBUTES_ERROR_TYPE - ] = status_code_str + metrics_attributes[_SPAN_ATTRIBUTES_ERROR_TYPE] = ( + status_code_str + ) span.set_status(Status(status)) 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 c5c3496248..7924fe0b57 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 @@ -98,9 +98,9 @@ def extract( if not key.startswith(OT_BAGGAGE_PREFIX): continue - baggage[ - key[len(OT_BAGGAGE_PREFIX) :] - ] = _extract_first_element(getter.get(carrier, key)) + baggage[key[len(OT_BAGGAGE_PREFIX) :]] = ( + _extract_first_element(getter.get(carrier, key)) + ) for key, value in baggage.items(): context = set_baggage(key, value, context) diff --git a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/app_service.py b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/app_service.py index 1e853acc57..b4daa4cc84 100644 --- a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/app_service.py +++ b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/app_service.py @@ -47,19 +47,19 @@ def detect(self) -> Resource: website_site_name = environ.get(_WEBSITE_SITE_NAME) if website_site_name: attributes[ResourceAttributes.SERVICE_NAME] = website_site_name - attributes[ - ResourceAttributes.CLOUD_PROVIDER - ] = CloudProviderValues.AZURE.value - attributes[ - ResourceAttributes.CLOUD_PLATFORM - ] = CloudPlatformValues.AZURE_APP_SERVICE.value + attributes[ResourceAttributes.CLOUD_PROVIDER] = ( + CloudProviderValues.AZURE.value + ) + attributes[ResourceAttributes.CLOUD_PLATFORM] = ( + CloudPlatformValues.AZURE_APP_SERVICE.value + ) azure_resource_uri = _get_azure_resource_uri(website_site_name) if azure_resource_uri: - attributes[ - ResourceAttributes.CLOUD_RESOURCE_ID - ] = azure_resource_uri - for (key, env_var) in _APP_SERVICE_ATTRIBUTE_ENV_VARS.items(): + attributes[ResourceAttributes.CLOUD_RESOURCE_ID] = ( + azure_resource_uri + ) + for key, env_var in _APP_SERVICE_ATTRIBUTE_ENV_VARS.items(): value = environ.get(env_var) if value: attributes[key] = value diff --git a/scripts/check_for_valid_readme.py b/scripts/check_for_valid_readme.py index 42446dd741..11b1fa81ac 100644 --- a/scripts/check_for_valid_readme.py +++ b/scripts/check_for_valid_readme.py @@ -1,4 +1,5 @@ """Test script to check given paths for valid README.rst files.""" + import argparse import sys from pathlib import Path