Skip to content

Commit 14cca2e

Browse files
Merge branch 'main' into django-fix-carrier-extract
2 parents 05e61ba + 07c52aa commit 14cca2e

File tree

14 files changed

+22
-30
lines changed

14 files changed

+22
-30
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def setUp(self):
410410
def test_request_attributes(self):
411411
self.scope["query_string"] = b"foo=bar"
412412
headers = []
413-
headers.append(("host".encode("utf8"), "test".encode("utf8")))
413+
headers.append((b"host", b"test"))
414414
self.scope["headers"] = headers
415415

416416
attrs = otel_asgi.collect_request_attributes(self.scope)

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,11 @@ def truncate_arg_value(value, max_len=1024):
235235
# Do not trace `Key Management Service` or `Secure Token Service` API calls
236236
# over concerns of security leaks.
237237
if aws_service not in {"kms", "sts"}:
238-
tags = dict(
239-
(name, value)
238+
tags = {
239+
name: value
240240
for (name, value) in zip(args_names, args)
241241
if name in args_traced
242-
)
242+
}
243243
tags = flatten_dict(tags)
244244

245245
for param_key, value in tags.items():

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def assert_span(
115115
expected[span_attributes_request_id] = request_id
116116

117117
self.assertSpanHasAttributes(span, expected)
118-
self.assertEqual("{}.{}".format(service, operation), span.name)
118+
self.assertEqual(f"{service}.{operation}", span.name)
119119
return span
120120

121121
@mock_ec2

instrumentation/opentelemetry-instrumentation-django/tests/test_middleware_asgi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ async def test_trace_response_headers(self):
358358
)
359359
self.assertEqual(
360360
response.headers["traceresponse"],
361-
"00-{0}-{1}-01".format(
361+
"00-{}-{}-01".format(
362362
format_trace_id(span.get_span_context().trace_id),
363363
format_span_id(span.get_span_context().span_id),
364364
),

instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_client.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,7 @@ def _intercept_server_stream(
174174
rpc_info.request = request_or_iterator
175175

176176
try:
177-
result = invoker(request_or_iterator, metadata)
178-
179-
for response in result:
180-
yield response
177+
yield from invoker(request_or_iterator, metadata)
181178
except grpc.RpcError as err:
182179
span.set_status(Status(StatusCode.ERROR))
183180
span.set_attribute(

instrumentation/opentelemetry-instrumentation-grpc/tests/protobuf/test_server_pb2.py

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

instrumentation/opentelemetry-instrumentation-grpc/tests/protobuf/test_server_pb2_grpc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from tests.protobuf import test_server_pb2 as test__server__pb2
44

55

6-
class GRPCTestServerStub(object):
6+
class GRPCTestServerStub:
77
"""Missing associated documentation comment in .proto file"""
88

99
def __init__(self, channel):
@@ -34,7 +34,7 @@ def __init__(self, channel):
3434
)
3535

3636

37-
class GRPCTestServerServicer(object):
37+
class GRPCTestServerServicer:
3838
"""Missing associated documentation comment in .proto file"""
3939

4040
def SimpleMethod(self, request, context):
@@ -92,7 +92,7 @@ def add_GRPCTestServerServicer_to_server(servicer, server):
9292

9393

9494
# This class is part of an EXPERIMENTAL API.
95-
class GRPCTestServer(object):
95+
class GRPCTestServer:
9696
"""Missing associated documentation comment in .proto file"""
9797

9898
@staticmethod

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,7 @@ def __call__(self, environ, start_response):
316316
def _end_span_after_iterating(iterable, span, tracer, token):
317317
try:
318318
with trace.use_span(span):
319-
for yielded in iterable:
320-
yield yielded
319+
yield from iterable
321320
finally:
322321
close = getattr(iterable, "close", None)
323322
if close:

scripts/generate_instrumentation_bootstrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def main():
8383
source = astor.to_source(tree)
8484

8585
with open(
86-
os.path.join(scripts_path, "license_header.txt"), "r", encoding="utf-8"
86+
os.path.join(scripts_path, "license_header.txt"), encoding="utf-8"
8787
) as header_file:
8888
header = header_file.read()
8989
source = _template.format(header=header, source=source)

scripts/generate_setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def main():
3737
root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
3838
with open(
3939
os.path.join(root_path, _template_dir, _template_name),
40-
"r",
4140
encoding="utf-8",
4241
) as template:
4342
setuppy_tmpl = Template(template.read())

tests/opentelemetry-docker-tests/tests/celery/conftest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
REDIS_HOST = os.getenv("REDIS_HOST", "localhost")
2828
REDIS_PORT = int(os.getenv("REDIS_PORT ", "6379"))
29-
REDIS_URL = "redis://{host}:{port}".format(host=REDIS_HOST, port=REDIS_PORT)
30-
BROKER_URL = "{redis}/{db}".format(redis=REDIS_URL, db=0)
31-
BACKEND_URL = "{redis}/{db}".format(redis=REDIS_URL, db=1)
29+
REDIS_URL = f"redis://{REDIS_HOST}:{REDIS_PORT}"
30+
BROKER_URL = f"{REDIS_URL}/0"
31+
BACKEND_URL = f"{REDIS_URL}/1"
3232

3333

3434
@pytest.fixture(scope="session")

tests/opentelemetry-docker-tests/tests/celery/test_celery_functional.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ def fn_task():
5151
assert run_span.parent.span_id == async_span.context.span_id
5252
assert run_span.context.trace_id == async_span.context.trace_id
5353

54-
assert async_span.instrumentation_info.name == "apply_async/{0}".format(
54+
assert async_span.instrumentation_info.name == "apply_async/{}".format(
5555
opentelemetry.instrumentation.celery.__name__
5656
)
57-
assert async_span.instrumentation_info.version == "apply_async/{0}".format(
57+
assert async_span.instrumentation_info.version == "apply_async/{}".format(
5858
opentelemetry.instrumentation.celery.__version__
5959
)
60-
assert run_span.instrumentation_info.name == "run/{0}".format(
60+
assert run_span.instrumentation_info.name == "run/{}".format(
6161
opentelemetry.instrumentation.celery.__name__
6262
)
63-
assert run_span.instrumentation_info.version == "run/{0}".format(
63+
assert run_span.instrumentation_info.version == "run/{}".format(
6464
opentelemetry.instrumentation.celery.__version__
6565
)
6666

@@ -489,9 +489,7 @@ class CelerySuperClass(celery.task.Task):
489489

490490
@classmethod
491491
def apply_async(cls, args=None, kwargs=None, **kwargs_):
492-
return super(CelerySuperClass, cls).apply_async(
493-
args=args, kwargs=kwargs, **kwargs_
494-
)
492+
return super().apply_async(args=args, kwargs=kwargs, **kwargs_)
495493

496494
def run(self, *args, **kwargs):
497495
if "stop" in kwargs:

tests/opentelemetry-docker-tests/tests/check_availability.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def wrapper():
6464
ex,
6565
)
6666
time.sleep(RETRY_INTERVAL)
67-
raise Exception("waiting for {} failed".format(func.__name__))
67+
raise Exception(f"waiting for {func.__name__} failed")
6868

6969
return wrapper
7070

tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/mixins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def tearDown(self):
113113

114114
def _check_span(self, span, name):
115115
if self.SQL_DB:
116-
name = "{0} {1}".format(name, self.SQL_DB)
116+
name = f"{name} {self.SQL_DB}"
117117
self.assertEqual(span.name, name)
118118
self.assertEqual(
119119
span.attributes.get(SpanAttributes.DB_NAME), self.SQL_DB

0 commit comments

Comments
 (0)