Skip to content

Commit

Permalink
test: integration test empty sqs polling span skipping
Browse files Browse the repository at this point in the history
  • Loading branch information
sagivoululumigo committed Sep 10, 2023
1 parent efda5e9 commit 88b4406
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/test/integration/boto3-sqs/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def run():
client = boto3.client("sqs", region_name="eu-central-1")
queue = client.create_queue(QueueName="test")

# Simulate polling an empty sqs queue
client.receive_message(QueueUrl=queue["QueueUrl"], MaxNumberOfMessages=1)
client.receive_message(QueueUrl=queue["QueueUrl"], MaxNumberOfMessages=1)
client.receive_message(QueueUrl=queue["QueueUrl"], MaxNumberOfMessages=1)

client.send_message(
QueueUrl=queue["QueueUrl"],
MessageBody="Message_1",
Expand Down
21 changes: 20 additions & 1 deletion src/test/integration/boto3-sqs/tests/test_boto3_sqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
class TestBoto3SqsSpans(unittest.TestCase):
def test_boto3_instrumentation(self):
spans_container = SpansContainer.parse_spans_from_file()
self.assertEqual(9, len(spans_container.spans))
self.assertEqual(12, len(spans_container.spans))

[
create_queue_span,
empty_sqs_poll_1_span,
empty_sqs_poll_2_span,
empty_sqs_poll_3_span,
send_message_1_span,
send_message_2_span,
receive_message_1_span,
Expand All @@ -21,6 +24,22 @@ def test_boto3_instrumentation(self):
after_iterator_break_span,
] = spans_container.spans

# Make sure that all the empty polling spans are marked as skipped
for span in [empty_sqs_poll_1_span, empty_sqs_poll_2_span, empty_sqs_poll_3_span]:
self.assertIsNotNone(span.get("attributes"))
self.assertEqual(span["attributes"].get("SKIP_EXPORT"), True)

# Make sure that other spans are not marked as skipped
for span in [create_queue_span,
send_message_1_span,
send_message_2_span,
receive_message_1_span,
receive_message_2_span,
consume_message_2_span,
consume_message_1_span,
receive_message_2_span]:
self.assertNotEqual(span.get("attributes", {}).get("SKIP_EXPORT"), True)

self.assertEqual(create_queue_span["name"], "SQS.CreateQueue")
self.assertIsNone(create_queue_span["parent_id"])

Expand Down

0 comments on commit 88b4406

Please sign in to comment.