diff --git a/src/lumigo_opentelemetry/instrumentations/botocore/parsers/__init__.py b/src/lumigo_opentelemetry/instrumentations/botocore/parsers/__init__.py index 959a9b8b..437f0e9f 100644 --- a/src/lumigo_opentelemetry/instrumentations/botocore/parsers/__init__.py +++ b/src/lumigo_opentelemetry/instrumentations/botocore/parsers/__init__.py @@ -138,12 +138,14 @@ def parse_request( span.set_attributes(attributes) @staticmethod - def _should_skip_empty_sqs_polling_response(operation_name: str, result: Dict[Any, Any]) -> bool: + def _should_skip_empty_sqs_polling_response( + operation_name: str, result: Dict[Any, Any] + ) -> bool: """ checks the sqs response & returns true if the request receive messages from SQS but no messages were returned """ - empty_sqs_poll = operation_name == 'ReceiveMessage' and 'Messages' not in result + empty_sqs_poll = operation_name == "ReceiveMessage" and "Messages" not in result return empty_sqs_poll and get_boolean_env_var(AUTO_FILTER_EMPTY_SQS, True) @staticmethod @@ -160,8 +162,10 @@ def parse_response( # Filter out sqs polls with empty response if SqsParser._should_skip_empty_sqs_polling_response(operation_name, result): - logger.debug('Not tracing empty SQS polling requests ' - f'(override by setting the {AUTO_FILTER_EMPTY_SQS} env var to false)') + logger.debug( + "Not tracing empty SQS polling requests " + f"(override by setting the {AUTO_FILTER_EMPTY_SQS} env var to false)" + ) set_span_no_export(span) diff --git a/src/lumigo_opentelemetry/libs/environment_variables.py b/src/lumigo_opentelemetry/libs/environment_variables.py index a63efc4a..6172c0b6 100644 --- a/src/lumigo_opentelemetry/libs/environment_variables.py +++ b/src/lumigo_opentelemetry/libs/environment_variables.py @@ -1 +1 @@ -AUTO_FILTER_EMPTY_SQS = 'AUTO_FILTER_EMPTY_SQS' +AUTO_FILTER_EMPTY_SQS = "AUTO_FILTER_EMPTY_SQS" diff --git a/src/lumigo_opentelemetry/resources/span_processor.py b/src/lumigo_opentelemetry/resources/span_processor.py index 0881da9a..f804ea49 100644 --- a/src/lumigo_opentelemetry/resources/span_processor.py +++ b/src/lumigo_opentelemetry/resources/span_processor.py @@ -6,13 +6,12 @@ class LumigoSpanProcessor(BatchSpanProcessor): - def on_end(self, span: ReadableSpan) -> None: if should_not_export_span(span): - logger.debug('Not exporting span because it has NO_EXPORT=True attribute') + logger.debug("Not exporting span because it has NO_EXPORT=True attribute") return - return super().on_end(span) + super().on_end(span) def should_not_export_span(span: ReadableSpan) -> bool: @@ -21,10 +20,10 @@ def should_not_export_span(span: ReadableSpan) -> bool: @param span: A readable span to check @return: True if the span should not be exported, False otherwise """ - return span.attributes.get('NO_EXPORT') is True + return span.attributes.get("NO_EXPORT") is True -def set_span_no_export(span: Span, no_export: bool = True): +def set_span_no_export(span: Span, no_export: bool = True) -> None: """ marks the span as a span not intended for export (for example in spans that create a lot of noise and customers do not want to trace) @@ -34,4 +33,4 @@ def set_span_no_export(span: Span, no_export: bool = True): @return: """ - span.set_attributes({'NO_EXPORT': no_export}) + span.set_attributes({"NO_EXPORT": no_export})