Skip to content

Commit

Permalink
chore: auto format code
Browse files Browse the repository at this point in the history
  • Loading branch information
sagivoululumigo committed Sep 7, 2023
1 parent a063aa7 commit 7b8613f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion src/lumigo_opentelemetry/libs/environment_variables.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
AUTO_FILTER_EMPTY_SQS = 'AUTO_FILTER_EMPTY_SQS'
AUTO_FILTER_EMPTY_SQS = "AUTO_FILTER_EMPTY_SQS"
11 changes: 5 additions & 6 deletions src/lumigo_opentelemetry/resources/span_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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})

0 comments on commit 7b8613f

Please sign in to comment.