File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
instrumentation/opentelemetry-instrumentation-botocore
src/opentelemetry/instrumentation/botocore/extensions Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 2020from opentelemetry .semconv .trace import SpanAttributes
2121from opentelemetry .trace .span import Span
2222
23- SUPPORTED_OPERATIONS = ["SendMessage" , "SendMessageBatch" , "ReceiveMessage" ]
23+ _SUPPORTED_OPERATIONS = ["SendMessage" , "SendMessageBatch" , "ReceiveMessage" ]
2424
2525
2626class _SqsExtension (_AwsSdkExtension ):
@@ -37,7 +37,7 @@ def extract_attributes(self, attributes: _AttributeMapT):
3737
3838 def on_success (self , span : Span , result : _BotoResultT ):
3939 operation = self ._call_context .operation
40- if operation in SUPPORTED_OPERATIONS :
40+ if operation in _SUPPORTED_OPERATIONS :
4141 if operation == "SendMessage" :
4242 span .set_attribute (
4343 SpanAttributes .MESSAGING_MESSAGE_ID ,
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ def test_sqs_messaging_send_message_batch(self):
6969 assert spans
7070 self .assertEqual (len (spans ), 2 )
7171 span = spans [1 ]
72+ self .assertEqual (span .attributes ["rpc.method" ], "SendMessageBatch" )
7273 self .assertEqual (
7374 span .attributes [SpanAttributes .MESSAGING_SYSTEM ], "aws.sqs"
7475 )
@@ -99,6 +100,7 @@ def test_sqs_messaging_receive_message(self):
99100 assert spans
100101 self .assertEqual (len (spans ), 3 )
101102 span = spans [- 1 ]
103+ self .assertEqual (span .attributes ["rpc.method" ], "ReceiveMessage" )
102104 self .assertEqual (
103105 span .attributes [SpanAttributes .MESSAGING_SYSTEM ], "aws.sqs"
104106 )
@@ -116,17 +118,16 @@ def test_sqs_messaging_receive_message(self):
116118
117119 @mock_sqs
118120 def test_sqs_messaging_failed_operation (self ):
119- try :
121+ with self . assertRaises ( Exception ) :
120122 self .client .send_message (
121123 QueueUrl = "non-existing" , MessageBody = "content"
122124 )
123- except Exception :
124- pass
125125
126126 spans = self .memory_exporter .get_finished_spans ()
127127 assert spans
128128 self .assertEqual (len (spans ), 1 )
129129 span = spans [0 ]
130+ self .assertEqual (span .attributes ["rpc.method" ], "SendMessage" )
130131 self .assertEqual (
131132 span .attributes [SpanAttributes .MESSAGING_SYSTEM ], "aws.sqs"
132133 )
You can’t perform that action at this time.
0 commit comments