Skip to content

Commit

Permalink
fix CR
Browse files Browse the repository at this point in the history
  • Loading branch information
CircleCI committed Nov 13, 2022
1 parent a5c71f3 commit dbe53cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace.span import Span

SUPPORTED_OPERATIONS = ["SendMessage", "SendMessageBatch", "ReceiveMessage"]
_SUPPORTED_OPERATIONS = ["SendMessage", "SendMessageBatch", "ReceiveMessage"]


class _SqsExtension(_AwsSdkExtension):
Expand All @@ -37,7 +37,7 @@ def extract_attributes(self, attributes: _AttributeMapT):

def on_success(self, span: Span, result: _BotoResultT):
operation = self._call_context.operation
if operation in SUPPORTED_OPERATIONS:
if operation in _SUPPORTED_OPERATIONS:
if operation == "SendMessage":
span.set_attribute(
SpanAttributes.MESSAGING_MESSAGE_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def test_sqs_messaging_send_message_batch(self):
assert spans
self.assertEqual(len(spans), 2)
span = spans[1]
self.assertEqual(span.attributes["rpc.method"], "SendMessageBatch")
self.assertEqual(
span.attributes[SpanAttributes.MESSAGING_SYSTEM], "aws.sqs"
)
Expand Down Expand Up @@ -99,6 +100,7 @@ def test_sqs_messaging_receive_message(self):
assert spans
self.assertEqual(len(spans), 3)
span = spans[-1]
self.assertEqual(span.attributes["rpc.method"], "ReceiveMessage")
self.assertEqual(
span.attributes[SpanAttributes.MESSAGING_SYSTEM], "aws.sqs"
)
Expand All @@ -116,17 +118,16 @@ def test_sqs_messaging_receive_message(self):

@mock_sqs
def test_sqs_messaging_failed_operation(self):
try:
with self.assertRaises(Exception):
self.client.send_message(
QueueUrl="non-existing", MessageBody="content"
)
except Exception:
pass

spans = self.memory_exporter.get_finished_spans()
assert spans
self.assertEqual(len(spans), 1)
span = spans[0]
self.assertEqual(span.attributes["rpc.method"], "SendMessage")
self.assertEqual(
span.attributes[SpanAttributes.MESSAGING_SYSTEM], "aws.sqs"
)
Expand Down

0 comments on commit dbe53cb

Please sign in to comment.