Skip to content

Commit 45a2679

Browse files
committed
Fix black an isort
1 parent 6f6c28d commit 45a2679

File tree

18 files changed

+121
-102
lines changed

18 files changed

+121
-102
lines changed

instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@
1313
# limitations under the License.
1414

1515
import urllib
16+
from timeit import default_timer
17+
from typing import Dict, List, Tuple, Union
18+
1619
from aiohttp import web
1720
from multidict import CIMultiDictProxy
18-
from timeit import default_timer
19-
from typing import Tuple, Dict, List, Union
2021

21-
from opentelemetry import context, trace, metrics
22+
from opentelemetry import context, metrics, trace
2223
from opentelemetry.context import _SUPPRESS_HTTP_INSTRUMENTATION_KEY
2324
from opentelemetry.instrumentation.aiohttp_server.package import _instruments
2425
from opentelemetry.instrumentation.aiohttp_server.version import __version__
2526
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
2627
from opentelemetry.instrumentation.utils import http_status_to_status_code
27-
from opentelemetry.propagators.textmap import Getter
2828
from opentelemetry.propagate import extract
29-
from opentelemetry.semconv.trace import SpanAttributes
29+
from opentelemetry.propagators.textmap import Getter
3030
from opentelemetry.semconv.metrics import MetricInstruments
31+
from opentelemetry.semconv.trace import SpanAttributes
3132
from opentelemetry.trace.status import Status, StatusCode
32-
from opentelemetry.util.http import get_excluded_urls
33-
from opentelemetry.util.http import remove_url_credentials
33+
from opentelemetry.util.http import get_excluded_urls, remove_url_credentials
3434

3535
_duration_attrs = [
3636
SpanAttributes.HTTP_METHOD,

instrumentation/opentelemetry-instrumentation-aiohttp-server/tests/test_aiohttp_server_integration.py

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from http import HTTPStatus
16+
17+
import aiohttp
1518
import pytest
1619
import pytest_asyncio
17-
import aiohttp
18-
from http import HTTPStatus
19-
from .utils import HTTPMethod
2020

2121
from opentelemetry import trace as trace_api
22-
from opentelemetry.test.test_base import TestBase
23-
from opentelemetry.instrumentation.aiohttp_server import AioHttpServerInstrumentor
22+
from opentelemetry.instrumentation.aiohttp_server import (
23+
AioHttpServerInstrumentor,
24+
)
2425
from opentelemetry.semconv.trace import SpanAttributes
26+
from opentelemetry.test.globals_test import reset_trace_globals
27+
from opentelemetry.test.test_base import TestBase
2528
from opentelemetry.util._importlib_metadata import entry_points
2629

27-
from opentelemetry.test.globals_test import (
28-
reset_trace_globals,
29-
)
30+
from .utils import HTTPMethod
3031

3132

3233
@pytest.fixture(scope="session")
@@ -54,8 +55,7 @@ async def server_fixture(tracer, aiohttp_server):
5455
AioHttpServerInstrumentor().instrument()
5556

5657
app = aiohttp.web.Application()
57-
app.add_routes(
58-
[aiohttp.web.get("/test-path", default_handler)])
58+
app.add_routes([aiohttp.web.get("/test-path", default_handler)])
5959

6060
server = await aiohttp_server(app)
6161
yield server, app
@@ -67,23 +67,28 @@ async def server_fixture(tracer, aiohttp_server):
6767

6868
def test_checking_instrumentor_pkg_installed():
6969

70-
(instrumentor_entrypoint,) = entry_points(group="opentelemetry_instrumentor", name="aiohttp-server")
70+
(instrumentor_entrypoint,) = entry_points(
71+
group="opentelemetry_instrumentor", name="aiohttp-server"
72+
)
7173
instrumentor = instrumentor_entrypoint.load()()
72-
assert (isinstance(instrumentor, AioHttpServerInstrumentor))
74+
assert isinstance(instrumentor, AioHttpServerInstrumentor)
7375

7476

7577
@pytest.mark.asyncio
76-
@pytest.mark.parametrize("url, expected_method, expected_status_code", [
77-
("/test-path", HTTPMethod.GET, HTTPStatus.OK),
78-
("/not-found", HTTPMethod.GET, HTTPStatus.NOT_FOUND)
79-
])
78+
@pytest.mark.parametrize(
79+
"url, expected_method, expected_status_code",
80+
[
81+
("/test-path", HTTPMethod.GET, HTTPStatus.OK),
82+
("/not-found", HTTPMethod.GET, HTTPStatus.NOT_FOUND),
83+
],
84+
)
8085
async def test_status_code_instrumentation(
8186
tracer,
8287
server_fixture,
8388
aiohttp_client,
8489
url,
8590
expected_method,
86-
expected_status_code
91+
expected_status_code,
8792
):
8893
_, memory_exporter = tracer
8994
server, app = server_fixture
@@ -98,8 +103,12 @@ async def test_status_code_instrumentation(
98103
[span] = memory_exporter.get_finished_spans()
99104

100105
assert expected_method.value == span.attributes[SpanAttributes.HTTP_METHOD]
101-
assert expected_status_code == span.attributes[SpanAttributes.HTTP_STATUS_CODE]
102-
103-
assert f"http://{server.host}:{server.port}{url}" == span.attributes[
104-
SpanAttributes.HTTP_URL
105-
]
106+
assert (
107+
expected_status_code
108+
== span.attributes[SpanAttributes.HTTP_STATUS_CODE]
109+
)
110+
111+
assert (
112+
f"http://{server.host}:{server.port}{url}"
113+
== span.attributes[SpanAttributes.HTTP_URL]
114+
)

instrumentation/opentelemetry-instrumentation-aiohttp-server/tests/utils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ class HTTPMethod(Enum):
2121
def __repr__(self):
2222
return f"{self.value}"
2323

24-
CONNECT = 'CONNECT'
25-
DELETE = 'DELETE'
26-
GET = 'GET'
27-
HEAD = 'HEAD'
28-
OPTIONS = 'OPTIONS'
29-
PATCH = 'PATCH'
30-
POST = 'POST'
31-
PUT = 'PUT'
32-
TRACE = 'TRACE'
24+
CONNECT = "CONNECT"
25+
DELETE = "DELETE"
26+
GET = "GET"
27+
HEAD = "HEAD"
28+
OPTIONS = "OPTIONS"
29+
PATCH = "PATCH"
30+
POST = "POST"
31+
PUT = "PUT"
32+
TRACE = "TRACE"

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def extract_attributes(
8282
attributes[SpanAttributes.MESSAGING_DESTINATION] = destination_name
8383

8484
# TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when opentelemetry-semantic-conventions 0.42b0 is released
85-
attributes["messaging.destination.name"] = cls._extract_input_arn(call_context)
85+
attributes["messaging.destination.name"] = cls._extract_input_arn(
86+
call_context
87+
)
8688
call_context.span_name = (
8789
f"{'phone_number' if is_phone_number else destination_name} send"
8890
)

instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_sns.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _test_publish_to_arn(self, arg_name: str):
122122
target_arn,
123123
# TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when
124124
# opentelemetry-semantic-conventions 0.42b0 is released
125-
span.attributes["messaging.destination.name"]
125+
span.attributes["messaging.destination.name"],
126126
)
127127

128128
@mock_sns
@@ -194,7 +194,7 @@ def test_publish_batch_to_topic(self):
194194
topic_arn,
195195
# TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when
196196
# opentelemetry-semantic-conventions 0.42b0 is released
197-
span.attributes["messaging.destination.name"]
197+
span.attributes["messaging.destination.name"],
198198
)
199199

200200
self.assert_injected_span(message1_attrs, span)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
from wrapt import wrap_function_wrapper
4444

4545
from opentelemetry import trace
46-
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4746
from opentelemetry.instrumentation.cassandra.package import _instruments
4847
from opentelemetry.instrumentation.cassandra.version import __version__
48+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4949
from opentelemetry.instrumentation.utils import unwrap
5050
from opentelemetry.semconv.trace import SpanAttributes
5151

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def add(x, y):
6363
from timeit import default_timer
6464
from typing import Collection, Iterable
6565

66+
from billiard import VERSION
6667
from billiard.einfo import ExceptionInfo
6768
from celery import signals # pylint: disable=no-name-in-module
6869

@@ -76,8 +77,6 @@ def add(x, y):
7677
from opentelemetry.propagators.textmap import Getter
7778
from opentelemetry.semconv.trace import SpanAttributes
7879
from opentelemetry.trace.status import Status, StatusCode
79-
from billiard import VERSION
80-
8180

8281
if VERSION >= (4, 0, 1):
8382
from billiard.einfo import ExceptionWithTraceback

instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import logging
1616

17-
from celery import registry # pylint: disable=no-name-in-module
1817
from billiard import VERSION
18+
from celery import registry # pylint: disable=no-name-in-module
1919

2020
from opentelemetry.semconv.trace import SpanAttributes
2121

instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ def instrument_consumer(consumer: Consumer, tracer_provider=None)
112112
from .package import _instruments
113113
from .utils import (
114114
KafkaPropertiesExtractor,
115-
_end_current_consume_span,
116115
_create_new_consume_span,
116+
_end_current_consume_span,
117117
_enrich_span,
118118
_get_span_name,
119119
_kafka_getter,

instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
from typing import List, Optional
33

44
from opentelemetry import context, propagate
5-
from opentelemetry.trace import SpanKind, Link
65
from opentelemetry.propagators import textmap
76
from opentelemetry.semconv.trace import (
87
MessagingDestinationKindValues,
98
MessagingOperationValues,
109
SpanAttributes,
1110
)
11+
from opentelemetry.trace import Link, SpanKind
1212

1313
_LOG = getLogger(__name__)
1414

instrumentation/opentelemetry-instrumentation-confluent-kafka/tests/test_instrumentation.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
# pylint: disable=no-name-in-module
1616

17-
from opentelemetry.semconv.trace import (
18-
SpanAttributes,
19-
MessagingDestinationKindValues,
20-
)
21-
from opentelemetry.test.test_base import TestBase
22-
from .utils import MockConsumer, MockedMessage
23-
2417
from confluent_kafka import Consumer, Producer
2518

2619
from opentelemetry.instrumentation.confluent_kafka import (
@@ -32,6 +25,13 @@
3225
KafkaContextGetter,
3326
KafkaContextSetter,
3427
)
28+
from opentelemetry.semconv.trace import (
29+
MessagingDestinationKindValues,
30+
SpanAttributes,
31+
)
32+
from opentelemetry.test.test_base import TestBase
33+
34+
from .utils import MockConsumer, MockedMessage
3535

3636

3737
class TestConfluentKafka(TestBase):

instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS,
4141
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST,
4242
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE,
43-
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_RESPONSE,
4443
OTEL_PYTHON_INSTRUMENTATION_HTTP_CAPTURE_ALL_METHODS,
4544
get_excluded_urls,
4645
)

instrumentation/opentelemetry-instrumentation-system-metrics/src/opentelemetry/instrumentation/system_metrics/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
"""
7777

7878
import gc
79-
import os
8079
import logging
80+
import os
8181
import threading
8282
from platform import python_implementation
8383
from typing import Collection, Dict, Iterable, List, Optional
@@ -358,7 +358,7 @@ def _instrument(self, **kwargs):
358358
if "process.runtime.gc_count" in self._config:
359359
if self._python_implementation == "pypy":
360360
_logger.warning(
361-
"The process.runtime.gc_count metric won't be collected because the interpreter is PyPy"
361+
"The process.runtime.gc_count metric won't be collected because the interpreter is PyPy"
362362
)
363363
else:
364364
self._meter.create_observable_counter(
@@ -367,7 +367,6 @@ def _instrument(self, **kwargs):
367367
description=f"Runtime {self._python_implementation} GC count",
368368
unit="bytes",
369369
)
370-
371370

372371
if "process.runtime.thread_count" in self._config:
373372
self._meter.create_observable_up_down_counter(

instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
from platform import python_implementation
1919
from unittest import mock, skipIf
2020

21-
from opentelemetry.sdk.metrics import MeterProvider
22-
from opentelemetry.sdk.metrics.export import InMemoryMetricReader
23-
from opentelemetry.test.test_base import TestBase
24-
2521
from opentelemetry.instrumentation.system_metrics import (
2622
SystemMetricsInstrumentor,
2723
)
24+
from opentelemetry.sdk.metrics import MeterProvider
25+
from opentelemetry.sdk.metrics.export import InMemoryMetricReader
26+
from opentelemetry.test.test_base import TestBase
2827

2928

3029
def _mock_netconnection():
@@ -120,12 +119,14 @@ def test_system_metrics_instrument(self):
120119
f"process.runtime.{self.implementation}.context_switches",
121120
f"process.runtime.{self.implementation}.cpu.utilization",
122121
]
123-
122+
124123
if self.implementation == "pypy":
125124
self.assertEqual(len(metric_names), 20)
126125
else:
127126
self.assertEqual(len(metric_names), 21)
128-
observer_names.append(f"process.runtime.{self.implementation}.gc_count",)
127+
observer_names.append(
128+
f"process.runtime.{self.implementation}.gc_count",
129+
)
129130

130131
for observer in metric_names:
131132
self.assertIn(observer, observer_names)
@@ -139,7 +140,7 @@ def test_runtime_metrics_instrument(self):
139140
"process.runtime.cpu.utilization": None,
140141
"process.runtime.context_switches": ["involuntary", "voluntary"],
141142
}
142-
143+
143144
if self.implementation != "pypy":
144145
runtime_config["process.runtime.gc_count"] = None
145146

@@ -166,7 +167,9 @@ def test_runtime_metrics_instrument(self):
166167
self.assertEqual(len(metric_names), 5)
167168
else:
168169
self.assertEqual(len(metric_names), 6)
169-
observer_names.append(f"process.runtime.{self.implementation}.gc_count")
170+
observer_names.append(
171+
f"process.runtime.{self.implementation}.gc_count"
172+
)
170173

171174
for observer in metric_names:
172175
self.assertIn(observer, observer_names)
@@ -181,9 +184,9 @@ def _assert_metrics(self, observer_name, reader, expected):
181184
for data_point in metric.data.data_points:
182185
for expect in expected:
183186
if (
184-
dict(data_point.attributes)
185-
== expect.attributes
186-
and metric.name == observer_name
187+
dict(data_point.attributes)
188+
== expect.attributes
189+
and metric.name == observer_name
187190
):
188191
self.assertEqual(
189192
data_point.value,
@@ -791,7 +794,9 @@ def test_runtime_cpu_time(self, mock_process_cpu_times):
791794
)
792795

793796
@mock.patch("gc.get_count")
794-
@skipIf(python_implementation().lower() == "pypy", "not supported for pypy")
797+
@skipIf(
798+
python_implementation().lower() == "pypy", "not supported for pypy"
799+
)
795800
def test_runtime_get_count(self, mock_gc_get_count):
796801
mock_gc_get_count.configure_mock(**{"return_value": (1, 2, 3)})
797802

0 commit comments

Comments
 (0)