use f-strings instead of format (#693)
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
This commit is contained in:
parent
2710e25b78
commit
fbb677a01d
|
|
@ -102,7 +102,7 @@ class DatadogSpanExporter(SpanExporter):
|
||||||
self._agent_writer = AgentWriter(uds_path=url_parsed.path)
|
self._agent_writer = AgentWriter(uds_path=url_parsed.path)
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Unknown scheme `%s` for agent URL" % url_parsed.scheme
|
f"Unknown scheme `{url_parsed.scheme}` for agent URL"
|
||||||
)
|
)
|
||||||
return self._agent_writer
|
return self._agent_writer
|
||||||
|
|
||||||
|
|
@ -225,7 +225,7 @@ def _get_span_name(span):
|
||||||
)
|
)
|
||||||
span_kind_name = span.kind.name if span.kind else None
|
span_kind_name = span.kind.name if span.kind else None
|
||||||
name = (
|
name = (
|
||||||
"{}.{}".format(instrumentation_name, span_kind_name)
|
f"{instrumentation_name}.{span_kind_name}"
|
||||||
if instrumentation_name and span_kind_name
|
if instrumentation_name and span_kind_name
|
||||||
else span.name
|
else span.name
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ def create_trace_config(
|
||||||
return
|
return
|
||||||
|
|
||||||
http_method = params.method.upper()
|
http_method = params.method.upper()
|
||||||
request_span_name = "HTTP {}".format(http_method)
|
request_span_name = f"HTTP {http_method}"
|
||||||
|
|
||||||
trace_config_ctx.span = trace_config_ctx.tracer.start_span(
|
trace_config_ctx.span = trace_config_ctx.tracer.start_span(
|
||||||
request_span_name, kind=SpanKind.CLIENT,
|
request_span_name, kind=SpanKind.CLIENT,
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class TestAioHttpIntegration(TestBase):
|
||||||
method: str = "GET",
|
method: str = "GET",
|
||||||
status_code: int = HTTPStatus.OK,
|
status_code: int = HTTPStatus.OK,
|
||||||
request_handler: typing.Callable = None,
|
request_handler: typing.Callable = None,
|
||||||
**kwargs
|
**kwargs,
|
||||||
) -> typing.Tuple[str, int]:
|
) -> typing.Tuple[str, int]:
|
||||||
"""Helper to start an aiohttp test server and send an actual HTTP request to it."""
|
"""Helper to start an aiohttp test server and send an actual HTTP request to it."""
|
||||||
|
|
||||||
|
|
@ -132,9 +132,7 @@ class TestAioHttpIntegration(TestBase):
|
||||||
(span_status, None),
|
(span_status, None),
|
||||||
{
|
{
|
||||||
SpanAttributes.HTTP_METHOD: "GET",
|
SpanAttributes.HTTP_METHOD: "GET",
|
||||||
SpanAttributes.HTTP_URL: "http://{}:{}/test-path?query=param#foobar".format(
|
SpanAttributes.HTTP_URL: f"http://{host}:{port}/test-path?query=param#foobar",
|
||||||
host, port
|
|
||||||
),
|
|
||||||
SpanAttributes.HTTP_STATUS_CODE: int(
|
SpanAttributes.HTTP_STATUS_CODE: int(
|
||||||
status_code
|
status_code
|
||||||
),
|
),
|
||||||
|
|
@ -167,7 +165,7 @@ class TestAioHttpIntegration(TestBase):
|
||||||
expected = "PATCH - /some/path"
|
expected = "PATCH - /some/path"
|
||||||
|
|
||||||
def request_hook(span: Span, params: aiohttp.TraceRequestStartParams):
|
def request_hook(span: Span, params: aiohttp.TraceRequestStartParams):
|
||||||
span.update_name("{} - {}".format(params.method, params.url.path))
|
span.update_name(f"{params.method} - {params.url.path}")
|
||||||
|
|
||||||
def response_hook(
|
def response_hook(
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
@ -198,7 +196,7 @@ class TestAioHttpIntegration(TestBase):
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
span.attributes[SpanAttributes.HTTP_URL],
|
span.attributes[SpanAttributes.HTTP_URL],
|
||||||
"http://{}:{}{}".format(host, port, path),
|
f"http://{host}:{port}{path}",
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
span.attributes[SpanAttributes.HTTP_STATUS_CODE], HTTPStatus.OK
|
span.attributes[SpanAttributes.HTTP_STATUS_CODE], HTTPStatus.OK
|
||||||
|
|
@ -227,9 +225,7 @@ class TestAioHttpIntegration(TestBase):
|
||||||
(StatusCode.UNSET, None),
|
(StatusCode.UNSET, None),
|
||||||
{
|
{
|
||||||
SpanAttributes.HTTP_METHOD: "GET",
|
SpanAttributes.HTTP_METHOD: "GET",
|
||||||
SpanAttributes.HTTP_URL: "http://{}:{}/some/path".format(
|
SpanAttributes.HTTP_URL: f"http://{host}:{port}/some/path",
|
||||||
host, port
|
|
||||||
),
|
|
||||||
SpanAttributes.HTTP_STATUS_CODE: int(HTTPStatus.OK),
|
SpanAttributes.HTTP_STATUS_CODE: int(HTTPStatus.OK),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -290,9 +286,7 @@ class TestAioHttpIntegration(TestBase):
|
||||||
(StatusCode.ERROR, None),
|
(StatusCode.ERROR, None),
|
||||||
{
|
{
|
||||||
SpanAttributes.HTTP_METHOD: "GET",
|
SpanAttributes.HTTP_METHOD: "GET",
|
||||||
SpanAttributes.HTTP_URL: "http://{}:{}/test_timeout".format(
|
SpanAttributes.HTTP_URL: f"http://{host}:{port}/test_timeout",
|
||||||
host, port
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
@ -319,9 +313,7 @@ class TestAioHttpIntegration(TestBase):
|
||||||
(StatusCode.ERROR, None),
|
(StatusCode.ERROR, None),
|
||||||
{
|
{
|
||||||
SpanAttributes.HTTP_METHOD: "GET",
|
SpanAttributes.HTTP_METHOD: "GET",
|
||||||
SpanAttributes.HTTP_URL: "http://{}:{}/test_too_many_redirects".format(
|
SpanAttributes.HTTP_URL: f"http://{host}:{port}/test_too_many_redirects",
|
||||||
host, port
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
@ -399,7 +391,7 @@ class TestAioHttpClientInstrumentor(TestBase):
|
||||||
span = self.assert_spans(1)
|
span = self.assert_spans(1)
|
||||||
self.assertEqual("GET", span.attributes[SpanAttributes.HTTP_METHOD])
|
self.assertEqual("GET", span.attributes[SpanAttributes.HTTP_METHOD])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"http://{}:{}/test-path".format(host, port),
|
f"http://{host}:{port}/test-path",
|
||||||
span.attributes[SpanAttributes.HTTP_URL],
|
span.attributes[SpanAttributes.HTTP_URL],
|
||||||
)
|
)
|
||||||
self.assertEqual(200, span.attributes[SpanAttributes.HTTP_STATUS_CODE])
|
self.assertEqual(200, span.attributes[SpanAttributes.HTTP_STATUS_CODE])
|
||||||
|
|
@ -502,13 +494,13 @@ class TestAioHttpClientInstrumentor(TestBase):
|
||||||
)
|
)
|
||||||
span = self.assert_spans(1)
|
span = self.assert_spans(1)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"http://{}:{}/test-path".format(host, port),
|
f"http://{host}:{port}/test-path",
|
||||||
span.attributes[SpanAttributes.HTTP_URL],
|
span.attributes[SpanAttributes.HTTP_URL],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_hooks(self):
|
def test_hooks(self):
|
||||||
def request_hook(span: Span, params: aiohttp.TraceRequestStartParams):
|
def request_hook(span: Span, params: aiohttp.TraceRequestStartParams):
|
||||||
span.update_name("{} - {}".format(params.method, params.url.path))
|
span.update_name(f"{params.method} - {params.url.path}")
|
||||||
|
|
||||||
def response_hook(
|
def response_hook(
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
|
||||||
|
|
@ -152,8 +152,9 @@ def get_default_span_details(scope: dict) -> Tuple[str, dict]:
|
||||||
Returns:
|
Returns:
|
||||||
a tuple of the span name, and any attributes to attach to the span.
|
a tuple of the span name, and any attributes to attach to the span.
|
||||||
"""
|
"""
|
||||||
span_name = scope.get("path", "").strip() or "HTTP {}".format(
|
span_name = (
|
||||||
scope.get("method", "").strip()
|
scope.get("path", "").strip()
|
||||||
|
or f"HTTP {scope.get('method', '').strip()}"
|
||||||
)
|
)
|
||||||
|
|
||||||
return span_name, {}
|
return span_name, {}
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ class BotoInstrumentor(BaseInstrumentor):
|
||||||
endpoint_name = getattr(instance, "host").split(".")[0]
|
endpoint_name = getattr(instance, "host").split(".")[0]
|
||||||
|
|
||||||
with self._tracer.start_as_current_span(
|
with self._tracer.start_as_current_span(
|
||||||
"{}.command".format(endpoint_name), kind=SpanKind.CONSUMER,
|
f"{endpoint_name}.command", kind=SpanKind.CONSUMER,
|
||||||
) as span:
|
) as span:
|
||||||
span.set_attribute("endpoint", endpoint_name)
|
span.set_attribute("endpoint", endpoint_name)
|
||||||
if args:
|
if args:
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ from opentelemetry.test.test_base import TestBase
|
||||||
def assert_span_http_status_code(span, code):
|
def assert_span_http_status_code(span, code):
|
||||||
"""Assert on the span's 'http.status_code' tag"""
|
"""Assert on the span's 'http.status_code' tag"""
|
||||||
tag = span.attributes[SpanAttributes.HTTP_STATUS_CODE]
|
tag = span.attributes[SpanAttributes.HTTP_STATUS_CODE]
|
||||||
assert tag == code, "%r != %r" % (tag, code)
|
assert tag == code, f"{tag} != {code}"
|
||||||
|
|
||||||
|
|
||||||
class TestBotoInstrumentor(TestBase):
|
class TestBotoInstrumentor(TestBase):
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ class BotocoreInstrumentor(BaseInstrumentor):
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
with self._tracer.start_as_current_span(
|
with self._tracer.start_as_current_span(
|
||||||
"{}".format(service_name), kind=SpanKind.CLIENT,
|
f"{service_name}", kind=SpanKind.CLIENT,
|
||||||
) as span:
|
) as span:
|
||||||
# inject trace context into payload headers for lambda Invoke
|
# inject trace context into payload headers for lambda Invoke
|
||||||
if BotocoreInstrumentor._is_lambda_invoke(
|
if BotocoreInstrumentor._is_lambda_invoke(
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ class CeleryInstrumentor(BaseInstrumentor):
|
||||||
|
|
||||||
logger.debug("prerun signal start task_id=%s", task_id)
|
logger.debug("prerun signal start task_id=%s", task_id)
|
||||||
|
|
||||||
operation_name = "{0}/{1}".format(_TASK_RUN, task.name)
|
operation_name = f"{_TASK_RUN}/{task.name}"
|
||||||
span = self._tracer.start_span(
|
span = self._tracer.start_span(
|
||||||
operation_name, context=tracectx, kind=trace.SpanKind.CONSUMER
|
operation_name, context=tracectx, kind=trace.SpanKind.CONSUMER
|
||||||
)
|
)
|
||||||
|
|
@ -178,7 +178,7 @@ class CeleryInstrumentor(BaseInstrumentor):
|
||||||
if task is None or task_id is None:
|
if task is None or task_id is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
operation_name = "{0}/{1}".format(_TASK_APPLY_ASYNC, task.name)
|
operation_name = f"{_TASK_APPLY_ASYNC}/{task.name}"
|
||||||
span = self._tracer.start_span(
|
span = self._tracer.start_span(
|
||||||
operation_name, kind=trace.SpanKind.PRODUCER
|
operation_name, kind=trace.SpanKind.PRODUCER
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ def set_attributes_from_context(span, context):
|
||||||
|
|
||||||
# set attribute name if not set specially for a key
|
# set attribute name if not set specially for a key
|
||||||
if attribute_name is None:
|
if attribute_name is None:
|
||||||
attribute_name = "celery.{}".format(key)
|
attribute_name = f"celery.{key}"
|
||||||
|
|
||||||
span.set_attribute(attribute_name, value)
|
span.set_attribute(attribute_name, value)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ class TestUtils(unittest.TestCase):
|
||||||
utils.retrieve_span(fn_task, task_id), (None, None)
|
utils.retrieve_span(fn_task, task_id), (None, None)
|
||||||
)
|
)
|
||||||
except Exception as ex: # pylint: disable=broad-except
|
except Exception as ex: # pylint: disable=broad-except
|
||||||
self.fail("Exception was raised: %s" % ex)
|
self.fail(f"Exception was raised: {ex}")
|
||||||
|
|
||||||
def test_task_id_from_protocol_v1(self):
|
def test_task_id_from_protocol_v1(self):
|
||||||
# ensures a `task_id` is properly returned when Protocol v1 is used.
|
# ensures a `task_id` is properly returned when Protocol v1 is used.
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ class _DjangoMiddleware(MiddlewareMixin):
|
||||||
return match.view_name
|
return match.view_name
|
||||||
|
|
||||||
except Resolver404:
|
except Resolver404:
|
||||||
return "HTTP {}".format(request.method)
|
return f"HTTP {request.method}"
|
||||||
|
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
# request.META is a dictionary containing all available HTTP headers
|
# request.META is a dictionary containing all available HTTP headers
|
||||||
|
|
@ -213,7 +213,7 @@ class _DjangoMiddleware(MiddlewareMixin):
|
||||||
if activation and span:
|
if activation and span:
|
||||||
add_response_attributes(
|
add_response_attributes(
|
||||||
span,
|
span,
|
||||||
"{} {}".format(response.status_code, response.reason_phrase),
|
f"{response.status_code} {response.reason_phrase}",
|
||||||
response,
|
response,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -349,10 +349,7 @@ class TestMiddleware(TestBase, WsgiTestBase):
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.headers["traceresponse"],
|
response.headers["traceresponse"],
|
||||||
"00-{0}-{1}-01".format(
|
f"00-{format_trace_id(span.get_span_context().trace_id)}-{format_span_id(span.get_span_context().span_id)}-01",
|
||||||
format_trace_id(span.get_span_context().trace_id),
|
|
||||||
format_span_id(span.get_span_context().span_id),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
self.memory_exporter.clear()
|
self.memory_exporter.clear()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,8 +192,7 @@ def _wrap_perform_request(
|
||||||
for member in _ATTRIBUTES_FROM_RESULT:
|
for member in _ATTRIBUTES_FROM_RESULT:
|
||||||
if member in rv:
|
if member in rv:
|
||||||
span.set_attribute(
|
span.set_attribute(
|
||||||
"elasticsearch.{0}".format(member),
|
f"elasticsearch.{member}", str(rv[member]),
|
||||||
str(rv[member]),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if callable(response_hook):
|
if callable(response_hook):
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ class TestElasticsearchIntegration(TestBase):
|
||||||
self.assertFalse(span.status.is_ok)
|
self.assertFalse(span.status.is_ok)
|
||||||
self.assertEqual(span.status.status_code, code)
|
self.assertEqual(span.status.status_code, code)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
span.status.description, "{}: {}".format(type(exc).__name__, exc)
|
span.status.description, f"{type(exc).__name__}: {exc}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_parent(self, request_mock):
|
def test_parent(self, request_mock):
|
||||||
|
|
|
||||||
|
|
@ -264,9 +264,7 @@ class _TraceMiddleware:
|
||||||
|
|
||||||
resource_name = resource.__class__.__name__
|
resource_name = resource.__class__.__name__
|
||||||
span.set_attribute("falcon.resource", resource_name)
|
span.set_attribute("falcon.resource", resource_name)
|
||||||
span.update_name(
|
span.update_name(f"{resource_name}.on_{req.method.lower()}")
|
||||||
"{0}.on_{1}".format(resource_name, req.method.lower())
|
|
||||||
)
|
|
||||||
|
|
||||||
def process_response(
|
def process_response(
|
||||||
self, req, resp, resource, req_succeeded=None
|
self, req, resp, resource, req_succeeded=None
|
||||||
|
|
@ -294,6 +292,7 @@ class _TraceMiddleware:
|
||||||
else:
|
else:
|
||||||
status = "500"
|
status = "500"
|
||||||
reason = "{}: {}".format(exc_type.__name__, exc)
|
reason = "{}: {}".format(exc_type.__name__, exc)
|
||||||
|
reason = f"{exc_type.__name__}: {exc}"
|
||||||
|
|
||||||
status = status.split(" ")[0]
|
status = status.split(" ")[0]
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,7 @@ class TestFalconInstrumentation(TestFalconBase):
|
||||||
spans = self.memory_exporter.get_finished_spans()
|
spans = self.memory_exporter.get_finished_spans()
|
||||||
self.assertEqual(len(spans), 1)
|
self.assertEqual(len(spans), 1)
|
||||||
span = spans[0]
|
span = spans[0]
|
||||||
self.assertEqual(
|
self.assertEqual(span.name, f"HelloWorldResource.on_{method.lower()}")
|
||||||
span.name, "HelloWorldResource.on_{0}".format(method.lower())
|
|
||||||
)
|
|
||||||
self.assertEqual(span.status.status_code, StatusCode.UNSET)
|
self.assertEqual(span.status.status_code, StatusCode.UNSET)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
span.status.description, None,
|
span.status.description, None,
|
||||||
|
|
@ -209,10 +207,7 @@ class TestFalconInstrumentation(TestFalconBase):
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
headers["traceresponse"],
|
headers["traceresponse"],
|
||||||
"00-{0}-{1}-01".format(
|
f"00-{format_trace_id(span.get_span_context().trace_id)}-{format_span_id(span.get_span_context().span_id)}-01",
|
||||||
format_trace_id(span.get_span_context().trace_id),
|
|
||||||
format_span_id(span.get_span_context().span_id),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set_global_response_propagator(orig)
|
set_global_response_propagator(orig)
|
||||||
|
|
|
||||||
|
|
@ -165,10 +165,7 @@ class TestProgrammatic(InstrumentationTest, TestBase, WsgiTestBase):
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
headers["traceresponse"],
|
headers["traceresponse"],
|
||||||
"00-{0}-{1}-01".format(
|
f"00-{trace.format_trace_id(span.get_span_context().trace_id)}-{trace.format_span_id(span.get_span_context().span_id)}-01",
|
||||||
trace.format_trace_id(span.get_span_context().trace_id),
|
|
||||||
trace.format_span_id(span.get_span_context().span_id),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set_global_response_propagator(orig)
|
set_global_response_propagator(orig)
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ class OpenTelemetryClientInterceptor(
|
||||||
span.set_status(
|
span.set_status(
|
||||||
Status(
|
Status(
|
||||||
status_code=StatusCode.ERROR,
|
status_code=StatusCode.ERROR,
|
||||||
description="{}: {}".format(type(exc).__name__, exc),
|
description=f"{type(exc).__name__}: {exc}",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
span.record_exception(exc)
|
span.record_exception(exc)
|
||||||
|
|
|
||||||
|
|
@ -122,8 +122,7 @@ class _OpenTelemetryServicerContext(grpc.ServicerContext):
|
||||||
)
|
)
|
||||||
self._active_span.set_status(
|
self._active_span.set_status(
|
||||||
Status(
|
Status(
|
||||||
status_code=StatusCode.ERROR,
|
status_code=StatusCode.ERROR, description=f"{code}:{details}",
|
||||||
description="{}:{}".format(code, details),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return self._servicer_context.abort(code, details)
|
return self._servicer_context.abort(code, details)
|
||||||
|
|
@ -142,7 +141,7 @@ class _OpenTelemetryServicerContext(grpc.ServicerContext):
|
||||||
self._active_span.set_status(
|
self._active_span.set_status(
|
||||||
Status(
|
Status(
|
||||||
status_code=StatusCode.ERROR,
|
status_code=StatusCode.ERROR,
|
||||||
description="{}:{}".format(code, details),
|
description=f"{code}:{details}",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return self._servicer_context.set_code(code)
|
return self._servicer_context.set_code(code)
|
||||||
|
|
@ -153,7 +152,7 @@ class _OpenTelemetryServicerContext(grpc.ServicerContext):
|
||||||
self._active_span.set_status(
|
self._active_span.set_status(
|
||||||
Status(
|
Status(
|
||||||
status_code=StatusCode.ERROR,
|
status_code=StatusCode.ERROR,
|
||||||
description="{}:{}".format(self.code, details),
|
description=f"{self.code}:{details}",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return self._servicer_context.set_details(details)
|
return self._servicer_context.set_details(details)
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,6 @@ def create_test_server(port):
|
||||||
TestServer(), server
|
TestServer(), server
|
||||||
)
|
)
|
||||||
|
|
||||||
server.add_insecure_port("localhost:{}".format(port))
|
server.add_insecure_port(f"localhost:{port}")
|
||||||
|
|
||||||
return server
|
return server
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
||||||
|
|
||||||
port = server.add_insecure_port("[::]:0")
|
port = server.add_insecure_port("[::]:0")
|
||||||
channel = grpc.insecure_channel("localhost:{:d}".format(port))
|
channel = grpc.insecure_channel(f"localhost:{port:d}")
|
||||||
|
|
||||||
rpc_call = "TestServicer/handler"
|
rpc_call = "TestServicer/handler"
|
||||||
try:
|
try:
|
||||||
|
|
@ -142,7 +142,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
||||||
|
|
||||||
port = server.add_insecure_port("[::]:0")
|
port = server.add_insecure_port("[::]:0")
|
||||||
channel = grpc.insecure_channel("localhost:{:d}".format(port))
|
channel = grpc.insecure_channel(f"localhost:{port:d}")
|
||||||
|
|
||||||
rpc_call = "TestServicer/test"
|
rpc_call = "TestServicer/test"
|
||||||
try:
|
try:
|
||||||
|
|
@ -168,7 +168,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
)
|
)
|
||||||
add_GRPCTestServerServicer_to_server(Servicer(), server)
|
add_GRPCTestServerServicer_to_server(Servicer(), server)
|
||||||
port = server.add_insecure_port("[::]:0")
|
port = server.add_insecure_port("[::]:0")
|
||||||
channel = grpc.insecure_channel("localhost:{:d}".format(port))
|
channel = grpc.insecure_channel(f"localhost:{port:d}")
|
||||||
|
|
||||||
rpc_call = "/GRPCTestServer/SimpleMethod"
|
rpc_call = "/GRPCTestServer/SimpleMethod"
|
||||||
request = Request(client_id=1, request_data="test")
|
request = Request(client_id=1, request_data="test")
|
||||||
|
|
@ -236,7 +236,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
)
|
)
|
||||||
add_GRPCTestServerServicer_to_server(TwoSpanServicer(), server)
|
add_GRPCTestServerServicer_to_server(TwoSpanServicer(), server)
|
||||||
port = server.add_insecure_port("[::]:0")
|
port = server.add_insecure_port("[::]:0")
|
||||||
channel = grpc.insecure_channel("localhost:{:d}".format(port))
|
channel = grpc.insecure_channel(f"localhost:{port:d}")
|
||||||
|
|
||||||
# setup the RPC
|
# setup the RPC
|
||||||
rpc_call = "/GRPCTestServer/SimpleMethod"
|
rpc_call = "/GRPCTestServer/SimpleMethod"
|
||||||
|
|
@ -297,7 +297,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
)
|
)
|
||||||
add_GRPCTestServerServicer_to_server(Servicer(), server)
|
add_GRPCTestServerServicer_to_server(Servicer(), server)
|
||||||
port = server.add_insecure_port("[::]:0")
|
port = server.add_insecure_port("[::]:0")
|
||||||
channel = grpc.insecure_channel("localhost:{:d}".format(port))
|
channel = grpc.insecure_channel(f"localhost:{port:d}")
|
||||||
|
|
||||||
# setup the RPC
|
# setup the RPC
|
||||||
rpc_call = "/GRPCTestServer/ServerStreamingMethod"
|
rpc_call = "/GRPCTestServer/ServerStreamingMethod"
|
||||||
|
|
@ -365,7 +365,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
)
|
)
|
||||||
add_GRPCTestServerServicer_to_server(TwoSpanServicer(), server)
|
add_GRPCTestServerServicer_to_server(TwoSpanServicer(), server)
|
||||||
port = server.add_insecure_port("[::]:0")
|
port = server.add_insecure_port("[::]:0")
|
||||||
channel = grpc.insecure_channel("localhost:{:d}".format(port))
|
channel = grpc.insecure_channel(f"localhost:{port:d}")
|
||||||
|
|
||||||
# setup the RPC
|
# setup the RPC
|
||||||
rpc_call = "/GRPCTestServer/ServerStreamingMethod"
|
rpc_call = "/GRPCTestServer/ServerStreamingMethod"
|
||||||
|
|
@ -433,7 +433,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
||||||
|
|
||||||
port = server.add_insecure_port("[::]:0")
|
port = server.add_insecure_port("[::]:0")
|
||||||
channel = grpc.insecure_channel("localhost:{:d}".format(port))
|
channel = grpc.insecure_channel(f"localhost:{port:d}")
|
||||||
|
|
||||||
active_span_before_call = trace.get_current_span()
|
active_span_before_call = trace.get_current_span()
|
||||||
try:
|
try:
|
||||||
|
|
@ -469,7 +469,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
||||||
|
|
||||||
port = server.add_insecure_port("[::]:0")
|
port = server.add_insecure_port("[::]:0")
|
||||||
channel = grpc.insecure_channel("localhost:{:d}".format(port))
|
channel = grpc.insecure_channel(f"localhost:{port:d}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
server.start()
|
server.start()
|
||||||
|
|
@ -533,7 +533,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
||||||
|
|
||||||
port = server.add_insecure_port("[::]:0")
|
port = server.add_insecure_port("[::]:0")
|
||||||
channel = grpc.insecure_channel("localhost:{:d}".format(port))
|
channel = grpc.insecure_channel(f"localhost:{port:d}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
server.start()
|
server.start()
|
||||||
|
|
@ -599,7 +599,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
server.add_generic_rpc_handlers((UnaryUnaryRpcHandler(handler),))
|
||||||
|
|
||||||
port = server.add_insecure_port("[::]:0")
|
port = server.add_insecure_port("[::]:0")
|
||||||
channel = grpc.insecure_channel("localhost:{:d}".format(port))
|
channel = grpc.insecure_channel(f"localhost:{port:d}")
|
||||||
|
|
||||||
rpc_call = "TestServicer/handler"
|
rpc_call = "TestServicer/handler"
|
||||||
|
|
||||||
|
|
@ -625,9 +625,7 @@ class TestOpenTelemetryServerInterceptor(TestBase):
|
||||||
self.assertEqual(span.status.status_code, StatusCode.ERROR)
|
self.assertEqual(span.status.status_code, StatusCode.ERROR)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
span.status.description,
|
span.status.description,
|
||||||
"{}:{}".format(
|
f"{grpc.StatusCode.FAILED_PRECONDITION}:{failure_message}",
|
||||||
grpc.StatusCode.FAILED_PRECONDITION, failure_message
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check attributes
|
# Check attributes
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ class ResponseInfo(typing.NamedTuple):
|
||||||
|
|
||||||
|
|
||||||
def _get_default_span_name(method: str) -> str:
|
def _get_default_span_name(method: str) -> str:
|
||||||
return "HTTP {}".format(method).strip()
|
return f"HTTP {method.strip()}"
|
||||||
|
|
||||||
|
|
||||||
def _apply_status_code(span: Span, status_code: int) -> None:
|
def _apply_status_code(span: Span, status_code: int) -> None:
|
||||||
|
|
|
||||||
|
|
@ -47,13 +47,13 @@ LEVELS = {
|
||||||
|
|
||||||
|
|
||||||
class LoggingInstrumentor(BaseInstrumentor): # pylint: disable=empty-docstring
|
class LoggingInstrumentor(BaseInstrumentor): # pylint: disable=empty-docstring
|
||||||
__doc__ = """An instrumentor for stdlib logging module.
|
__doc__ = f"""An instrumentor for stdlib logging module.
|
||||||
|
|
||||||
This instrumentor injects tracing context into logging records and optionally sets the global logging format to the following:
|
This instrumentor injects tracing context into logging records and optionally sets the global logging format to the following:
|
||||||
|
|
||||||
.. code-block::
|
.. code-block::
|
||||||
|
|
||||||
{default_logging_format}
|
{DEFAULT_LOGGING_FORMAT}
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
tracer_provider: Tracer provider instance that can be used to fetch a tracer.
|
tracer_provider: Tracer provider instance that can be used to fetch a tracer.
|
||||||
|
|
@ -68,9 +68,7 @@ class LoggingInstrumentor(BaseInstrumentor): # pylint: disable=empty-docstring
|
||||||
logging.FATAL
|
logging.FATAL
|
||||||
|
|
||||||
See `BaseInstrumentor`
|
See `BaseInstrumentor`
|
||||||
""".format(
|
"""
|
||||||
default_logging_format=DEFAULT_LOGGING_FORMAT
|
|
||||||
)
|
|
||||||
|
|
||||||
_old_factory = None
|
_old_factory = None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ def _wrap_cmd(tracer, cmd, wrapped, instance, args, kwargs):
|
||||||
else:
|
else:
|
||||||
vals = _get_query_string(args[0])
|
vals = _get_query_string(args[0])
|
||||||
|
|
||||||
query = "{}{}{}".format(cmd, " " if vals else "", vals)
|
query = f"{cmd}{' ' if vals else ''}{vals}"
|
||||||
span.set_attribute(SpanAttributes.DB_STATEMENT, query)
|
span.set_attribute(SpanAttributes.DB_STATEMENT, query)
|
||||||
|
|
||||||
_set_connection_attributes(span, instance)
|
_set_connection_attributes(span, instance)
|
||||||
|
|
@ -188,10 +188,10 @@ class PymemcacheInstrumentor(BaseInstrumentor):
|
||||||
for cmd in COMMANDS:
|
for cmd in COMMANDS:
|
||||||
_wrap(
|
_wrap(
|
||||||
"pymemcache.client.base",
|
"pymemcache.client.base",
|
||||||
"Client.{}".format(cmd),
|
f"Client.{cmd}",
|
||||||
_wrap_cmd(tracer, cmd),
|
_wrap_cmd(tracer, cmd),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _uninstrument(self, **kwargs):
|
def _uninstrument(self, **kwargs):
|
||||||
for command in COMMANDS:
|
for command in COMMANDS:
|
||||||
unwrap(pymemcache.client.base.Client, "{}".format(command))
|
unwrap(pymemcache.client.base.Client, f"{command}")
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,7 @@ class PymemcacheHashClientTestCase(TestBase):
|
||||||
ip = TEST_HOST
|
ip = TEST_HOST
|
||||||
|
|
||||||
for vals in mock_socket_values:
|
for vals in mock_socket_values:
|
||||||
url_string = "{}:{}".format(ip, current_port)
|
url_string = f"{ip}:{current_port}"
|
||||||
clnt_pool = self.make_client_pool(
|
clnt_pool = self.make_client_pool(
|
||||||
(ip, current_port), vals, **kwargs
|
(ip, current_port), vals, **kwargs
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -121,10 +121,7 @@ class TestProgrammatic(InstrumentationTest, TestBase, WsgiTestBase):
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
headers["traceresponse"],
|
headers["traceresponse"],
|
||||||
"00-{0}-{1}-01".format(
|
f"00-{trace.format_trace_id(span.get_span_context().trace_id)}-{trace.format_span_id(span.get_span_context().span_id)}-01",
|
||||||
trace.format_trace_id(span.get_span_context().trace_id),
|
|
||||||
trace.format_span_id(span.get_span_context().span_id),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set_global_response_propagator(orig)
|
set_global_response_propagator(orig)
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ def _format_command_args(args):
|
||||||
|
|
||||||
if length + len(cmd) > cmd_max_len:
|
if length + len(cmd) > cmd_max_len:
|
||||||
prefix = cmd[: cmd_max_len - length]
|
prefix = cmd[: cmd_max_len - length]
|
||||||
out.append("%s%s" % (prefix, value_too_long_mark))
|
out.append(f"{prefix}{value_too_long_mark}")
|
||||||
break
|
break
|
||||||
|
|
||||||
out.append(cmd)
|
out.append(cmd)
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ def _uninstrument_from(instr_root, restore_as_bound_func=False):
|
||||||
|
|
||||||
def get_default_span_name(method):
|
def get_default_span_name(method):
|
||||||
"""Default implementation for name_callback, returns HTTP {method_name}."""
|
"""Default implementation for name_callback, returns HTTP {method_name}."""
|
||||||
return "HTTP {}".format(method).strip()
|
return f"HTTP {method.strip()}"
|
||||||
|
|
||||||
|
|
||||||
class RequestsInstrumentor(BaseInstrumentor):
|
class RequestsInstrumentor(BaseInstrumentor):
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ def implement_span_estimator(
|
||||||
name = estimator.__class__.__name__
|
name = estimator.__class__.__name__
|
||||||
logger.debug("Instrumenting: %s.%s", name, func.__name__)
|
logger.debug("Instrumenting: %s.%s", name, func.__name__)
|
||||||
attributes = attributes or {}
|
attributes = attributes or {}
|
||||||
name = "{cls}.{func}".format(cls=name, func=func.__name__)
|
name = f"{name}.{func.__name__}"
|
||||||
return implement_span_function(func, name, attributes)
|
return implement_span_function(func, name, attributes)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@ def _get_attributes_from_request(request):
|
||||||
def _get_operation_name(handler, request):
|
def _get_operation_name(handler, request):
|
||||||
full_class_name = type(handler).__name__
|
full_class_name = type(handler).__name__
|
||||||
class_name = full_class_name.rsplit(".")[-1]
|
class_name = full_class_name.rsplit(".")[-1]
|
||||||
return "{0}.{1}".format(class_name, request.method.lower())
|
return f"{class_name}.{request.method.lower()}"
|
||||||
|
|
||||||
|
|
||||||
def _start_span(tracer, handler, start_time) -> _TraceContext:
|
def _start_span(tracer, handler, start_time) -> _TraceContext:
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ def _finish_tracing_callback(future, span, response_hook):
|
||||||
if span.is_recording() and exc:
|
if span.is_recording() and exc:
|
||||||
if isinstance(exc, HTTPError):
|
if isinstance(exc, HTTPError):
|
||||||
status_code = exc.code
|
status_code = exc.code
|
||||||
description = "{}: {}".format(type(exc).__name__, exc)
|
description = f"{type(exc).__name__}: {exc}"
|
||||||
else:
|
else:
|
||||||
status_code = future.result().code
|
status_code = future.result().code
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -453,10 +453,7 @@ class TestTornadoInstrumentation(TornadoTest):
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
headers["traceresponse"],
|
headers["traceresponse"],
|
||||||
"00-{0}-{1}-01".format(
|
f"00-{trace.format_trace_id(server_span.get_span_context().trace_id)}-{trace.format_span_id(server_span.get_span_context().span_id)}-01",
|
||||||
trace.format_trace_id(server_span.get_span_context().trace_id),
|
|
||||||
trace.format_span_id(server_span.get_span_context().span_id),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.memory_exporter.clear()
|
self.memory_exporter.clear()
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ def _instrument(
|
||||||
method = request.get_method().upper()
|
method = request.get_method().upper()
|
||||||
url = request.full_url
|
url = request.full_url
|
||||||
|
|
||||||
span_name = "HTTP {}".format(method).strip()
|
span_name = f"HTTP {method}".strip()
|
||||||
|
|
||||||
url = remove_url_credentials(url)
|
url = remove_url_credentials(url)
|
||||||
|
|
||||||
|
|
@ -215,9 +215,9 @@ def _instrument(
|
||||||
|
|
||||||
ver_ = str(getattr(result, "version", ""))
|
ver_ = str(getattr(result, "version", ""))
|
||||||
if ver_:
|
if ver_:
|
||||||
labels[SpanAttributes.HTTP_FLAVOR] = "{}.{}".format(
|
labels[
|
||||||
ver_[:1], ver_[:-1]
|
SpanAttributes.HTTP_FLAVOR
|
||||||
)
|
] = f"{ver_[:1]}.{ver_[:-1]}"
|
||||||
|
|
||||||
if callable(response_hook):
|
if callable(response_hook):
|
||||||
response_hook(span, request, result)
|
response_hook(span, request, result)
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ def _instrument(
|
||||||
headers = _prepare_headers(kwargs)
|
headers = _prepare_headers(kwargs)
|
||||||
body = _get_url_open_arg("body", args, kwargs)
|
body = _get_url_open_arg("body", args, kwargs)
|
||||||
|
|
||||||
span_name = "HTTP {}".format(method.strip())
|
span_name = f"HTTP {method.strip()}"
|
||||||
span_attributes = {
|
span_attributes = {
|
||||||
SpanAttributes.HTTP_METHOD: method,
|
SpanAttributes.HTTP_METHOD: method,
|
||||||
SpanAttributes.HTTP_URL: url,
|
SpanAttributes.HTTP_URL: url,
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ def add_response_attributes(
|
||||||
|
|
||||||
def get_default_span_name(environ):
|
def get_default_span_name(environ):
|
||||||
"""Default implementation for name_callback, returns HTTP {METHOD_NAME}."""
|
"""Default implementation for name_callback, returns HTTP {METHOD_NAME}."""
|
||||||
return "HTTP {}".format(environ.get("REQUEST_METHOD", "")).strip()
|
return f"HTTP {environ.get('REQUEST_METHOD', '')}".strip()
|
||||||
|
|
||||||
|
|
||||||
class OpenTelemetryMiddleware:
|
class OpenTelemetryMiddleware:
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,12 @@ subprocess_run = subprocess.run
|
||||||
|
|
||||||
def extraargs_help(calledcmd):
|
def extraargs_help(calledcmd):
|
||||||
return cleandoc(
|
return cleandoc(
|
||||||
"""
|
f"""
|
||||||
Additional arguments to pass on to {}.
|
Additional arguments to pass on to {calledcmd}.
|
||||||
|
|
||||||
This is collected from any trailing arguments passed to `%(prog)s`.
|
This is collected from any trailing arguments passed to `%(prog)s`.
|
||||||
Use an initial `--` to separate them from regular arguments.
|
Use an initial `--` to separate them from regular arguments.
|
||||||
""".format(
|
"""
|
||||||
calledcmd
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -403,7 +401,7 @@ def execute_args(args):
|
||||||
rootpath = find_projectroot()
|
rootpath = find_projectroot()
|
||||||
targets = find_targets(args.mode, rootpath)
|
targets = find_targets(args.mode, rootpath)
|
||||||
if not targets:
|
if not targets:
|
||||||
sys.exit("Error: No targets selected (root: {})".format(rootpath))
|
sys.exit(f"Error: No targets selected (root: {rootpath})")
|
||||||
|
|
||||||
def fmt_for_path(fmt, path):
|
def fmt_for_path(fmt, path):
|
||||||
return fmt.format(
|
return fmt.format(
|
||||||
|
|
@ -419,7 +417,7 @@ def execute_args(args):
|
||||||
)
|
)
|
||||||
if result is not None and result.returncode not in args.allowexitcode:
|
if result is not None and result.returncode not in args.allowexitcode:
|
||||||
print(
|
print(
|
||||||
"'{}' failed with code {}".format(cmd, result.returncode),
|
f"'{cmd}' failed with code {result.returncode}",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
sys.exit(result.returncode)
|
sys.exit(result.returncode)
|
||||||
|
|
@ -474,7 +472,7 @@ def install_args(args):
|
||||||
if args.with_test_deps:
|
if args.with_test_deps:
|
||||||
extras.append("test")
|
extras.append("test")
|
||||||
if extras:
|
if extras:
|
||||||
allfmt += "[{}]".format(",".join(extras))
|
allfmt += f"[{','.join(extras)}]"
|
||||||
# note the trailing single quote, to close the quote opened above.
|
# note the trailing single quote, to close the quote opened above.
|
||||||
allfmt += "'"
|
allfmt += "'"
|
||||||
|
|
||||||
|
|
@ -548,9 +546,9 @@ def update_changelog(path, version, new_entry):
|
||||||
try:
|
try:
|
||||||
with open(path, encoding="utf-8") as changelog:
|
with open(path, encoding="utf-8") as changelog:
|
||||||
text = changelog.read()
|
text = changelog.read()
|
||||||
if "## [{}]".format(version) in text:
|
if f"## [{version}]" in text:
|
||||||
raise AttributeError(
|
raise AttributeError(
|
||||||
"{} already contans version {}".format(path, version)
|
f"{path} already contans version {version}"
|
||||||
)
|
)
|
||||||
with open(path, encoding="utf-8") as changelog:
|
with open(path, encoding="utf-8") as changelog:
|
||||||
for line in changelog:
|
for line in changelog:
|
||||||
|
|
@ -562,11 +560,11 @@ def update_changelog(path, version, new_entry):
|
||||||
unreleased_changes = True
|
unreleased_changes = True
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print("file missing: {}".format(path))
|
print(f"file missing: {path}")
|
||||||
return
|
return
|
||||||
|
|
||||||
if unreleased_changes:
|
if unreleased_changes:
|
||||||
print("updating: {}".format(path))
|
print(f"updating: {path}")
|
||||||
text = re.sub(r"## \[Unreleased\].*", new_entry, text)
|
text = re.sub(r"## \[Unreleased\].*", new_entry, text)
|
||||||
with open(path, "w", encoding="utf-8") as changelog:
|
with open(path, "w", encoding="utf-8") as changelog:
|
||||||
changelog.write(text)
|
changelog.write(text)
|
||||||
|
|
@ -617,10 +615,7 @@ def update_version_files(targets, version, packages):
|
||||||
print("updating version.py files")
|
print("updating version.py files")
|
||||||
targets = filter_packages(targets, packages)
|
targets = filter_packages(targets, packages)
|
||||||
update_files(
|
update_files(
|
||||||
targets,
|
targets, "version.py", "__version__ .*", f'__version__ = "{version}"',
|
||||||
"version.py",
|
|
||||||
"__version__ .*",
|
|
||||||
'__version__ = "{}"'.format(version),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -638,7 +633,7 @@ def update_dependencies(targets, version, packages):
|
||||||
update_files(
|
update_files(
|
||||||
targets,
|
targets,
|
||||||
"setup.cfg",
|
"setup.cfg",
|
||||||
r"({}.*)==(.*)".format(package_name),
|
fr"({package_name}.*)==(.*)",
|
||||||
r"\1== " + version,
|
r"\1== " + version,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -648,14 +643,14 @@ def update_files(targets, filename, search, replace):
|
||||||
for target in targets:
|
for target in targets:
|
||||||
curr_file = find(filename, target)
|
curr_file = find(filename, target)
|
||||||
if curr_file is None:
|
if curr_file is None:
|
||||||
print("file missing: {}/{}".format(target, filename))
|
print(f"file missing: {target}/{filename}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
with open(curr_file, encoding="utf-8") as _file:
|
with open(curr_file, encoding="utf-8") as _file:
|
||||||
text = _file.read()
|
text = _file.read()
|
||||||
|
|
||||||
if replace in text:
|
if replace in text:
|
||||||
print("{} already contains {}".format(curr_file, replace))
|
print(f"{curr_file} already contains {replace}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
with open(curr_file, "w", encoding="utf-8") as _file:
|
with open(curr_file, "w", encoding="utf-8") as _file:
|
||||||
|
|
@ -681,7 +676,7 @@ def release_args(args):
|
||||||
packages = None
|
packages = None
|
||||||
if "packages" in mcfg:
|
if "packages" in mcfg:
|
||||||
packages = mcfg["packages"].split()
|
packages = mcfg["packages"].split()
|
||||||
print("update {} packages to {}".format(group, version))
|
print(f"update {group} packages to {version}")
|
||||||
update_dependencies(targets, version, packages)
|
update_dependencies(targets, version, packages)
|
||||||
update_version_files(targets, version, packages)
|
update_version_files(targets, version, packages)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,7 @@ def main():
|
||||||
instruments = (name,)
|
instruments = (name,)
|
||||||
|
|
||||||
table.append(
|
table.append(
|
||||||
"| [{0}](./{0}) | {1} |".format(
|
f"| [{instrumentation}](./{instrumentation}) | {','.join(instruments)} |"
|
||||||
instrumentation, ",".join(instruments)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(
|
with open(
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ class AwsXRayFormat(TextMapPropagator):
|
||||||
if not span_context.is_valid:
|
if not span_context.is_valid:
|
||||||
return
|
return
|
||||||
|
|
||||||
otel_trace_id = "{:032x}".format(span_context.trace_id)
|
otel_trace_id = f"{span_context.trace_id:032x}"
|
||||||
xray_trace_id = TRACE_ID_DELIMITER.join(
|
xray_trace_id = TRACE_ID_DELIMITER.join(
|
||||||
[
|
[
|
||||||
TRACE_ID_VERSION,
|
TRACE_ID_VERSION,
|
||||||
|
|
@ -291,7 +291,7 @@ class AwsXRayFormat(TextMapPropagator):
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
parent_id = "{:016x}".format(span_context.span_id)
|
parent_id = f"{span_context.span_id:016x}"
|
||||||
|
|
||||||
sampling_flag = (
|
sampling_flag = (
|
||||||
IS_SAMPLED
|
IS_SAMPLED
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ _root = r"OTEL_PYTHON_{}"
|
||||||
|
|
||||||
def get_traced_request_attrs(instrumentation):
|
def get_traced_request_attrs(instrumentation):
|
||||||
traced_request_attrs = environ.get(
|
traced_request_attrs = environ.get(
|
||||||
_root.format("{}_TRACED_REQUEST_ATTRS".format(instrumentation)), []
|
_root.format(f"{instrumentation}_TRACED_REQUEST_ATTRS"), []
|
||||||
)
|
)
|
||||||
|
|
||||||
if traced_request_attrs:
|
if traced_request_attrs:
|
||||||
|
|
@ -49,7 +49,7 @@ def get_traced_request_attrs(instrumentation):
|
||||||
|
|
||||||
def get_excluded_urls(instrumentation):
|
def get_excluded_urls(instrumentation):
|
||||||
excluded_urls = environ.get(
|
excluded_urls = environ.get(
|
||||||
_root.format("{}_EXCLUDED_URLS".format(instrumentation)), []
|
_root.format(f"{instrumentation}_EXCLUDED_URLS"), []
|
||||||
)
|
)
|
||||||
|
|
||||||
return parse_excluded_urls(excluded_urls)
|
return parse_excluded_urls(excluded_urls)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue