From 209aab22d3e5d566f22b835d0e11c0c20b021737 Mon Sep 17 00:00:00 2001 From: Rey Abolofia Date: Mon, 1 Apr 2024 09:33:02 -0700 Subject: [PATCH 1/2] Small performance improvements to %s formatted strings. --- datadog_lambda/tracing.py | 6 +++--- datadog_lambda/xray.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/datadog_lambda/tracing.py b/datadog_lambda/tracing.py index ae2a0112..2272fd14 100644 --- a/datadog_lambda/tracing.py +++ b/datadog_lambda/tracing.py @@ -529,8 +529,8 @@ def get_dd_trace_context_obj(): xray_context = _get_xray_trace_context() # xray (sub)segment except Exception as e: logger.debug( - "get_dd_trace_context couldn't read from segment from x-ray, with error %s" - % e + "get_dd_trace_context couldn't read from segment from x-ray, with error %s", + e ) if not xray_context: return None @@ -1051,7 +1051,7 @@ def create_inferred_span_from_sqs_event(event, context): except Exception as e: logger.debug( - "Unable to create upstream span from SQS message, with error %s" % e + "Unable to create upstream span from SQS message, with error %s", e ) pass diff --git a/datadog_lambda/xray.py b/datadog_lambda/xray.py index 88d108f5..0b7b08c0 100644 --- a/datadog_lambda/xray.py +++ b/datadog_lambda/xray.py @@ -31,11 +31,11 @@ def send(host_port_tuple, payload): sock.connect(host_port_tuple) sock.send(payload.encode("utf-8")) except Exception as e_send: - logger.error("Error occurred submitting to xray daemon: %s", str(e_send)) + logger.error("Error occurred submitting to xray daemon: %s", e_send) try: sock.close() except Exception as e_close: - logger.error("Error while closing the socket: %s", str(e_close)) + logger.error("Error while closing the socket: %s", e_close) def build_segment_payload(payload): From 4f32de103ffdd2ec561deb7dfb9318be26baa994 Mon Sep 17 00:00:00 2001 From: Rey Abolofia Date: Mon, 1 Apr 2024 10:23:24 -0700 Subject: [PATCH 2/2] Linting. --- datadog_lambda/tracing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datadog_lambda/tracing.py b/datadog_lambda/tracing.py index 2272fd14..2c1e5bc7 100644 --- a/datadog_lambda/tracing.py +++ b/datadog_lambda/tracing.py @@ -530,7 +530,7 @@ def get_dd_trace_context_obj(): except Exception as e: logger.debug( "get_dd_trace_context couldn't read from segment from x-ray, with error %s", - e + e, ) if not xray_context: return None