File tree 2 files changed +6
-5
lines changed
instrumentation/opentelemetry-instrumentation-botocore
src/opentelemetry/instrumentation/botocore/extensions
2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 20
20
from opentelemetry .semconv .trace import SpanAttributes
21
21
from opentelemetry .trace .span import Span
22
22
23
- SUPPORTED_OPERATIONS = ["SendMessage" , "SendMessageBatch" , "ReceiveMessage" ]
23
+ _SUPPORTED_OPERATIONS = ["SendMessage" , "SendMessageBatch" , "ReceiveMessage" ]
24
24
25
25
26
26
class _SqsExtension (_AwsSdkExtension ):
@@ -37,7 +37,7 @@ def extract_attributes(self, attributes: _AttributeMapT):
37
37
38
38
def on_success (self , span : Span , result : _BotoResultT ):
39
39
operation = self ._call_context .operation
40
- if operation in SUPPORTED_OPERATIONS :
40
+ if operation in _SUPPORTED_OPERATIONS :
41
41
if operation == "SendMessage" :
42
42
span .set_attribute (
43
43
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):
69
69
assert spans
70
70
self .assertEqual (len (spans ), 2 )
71
71
span = spans [1 ]
72
+ self .assertEqual (span .attributes ["rpc.method" ], "SendMessageBatch" )
72
73
self .assertEqual (
73
74
span .attributes [SpanAttributes .MESSAGING_SYSTEM ], "aws.sqs"
74
75
)
@@ -99,6 +100,7 @@ def test_sqs_messaging_receive_message(self):
99
100
assert spans
100
101
self .assertEqual (len (spans ), 3 )
101
102
span = spans [- 1 ]
103
+ self .assertEqual (span .attributes ["rpc.method" ], "ReceiveMessage" )
102
104
self .assertEqual (
103
105
span .attributes [SpanAttributes .MESSAGING_SYSTEM ], "aws.sqs"
104
106
)
@@ -116,17 +118,16 @@ def test_sqs_messaging_receive_message(self):
116
118
117
119
@mock_sqs
118
120
def test_sqs_messaging_failed_operation (self ):
119
- try :
121
+ with self . assertRaises ( Exception ) :
120
122
self .client .send_message (
121
123
QueueUrl = "non-existing" , MessageBody = "content"
122
124
)
123
- except Exception :
124
- pass
125
125
126
126
spans = self .memory_exporter .get_finished_spans ()
127
127
assert spans
128
128
self .assertEqual (len (spans ), 1 )
129
129
span = spans [0 ]
130
+ self .assertEqual (span .attributes ["rpc.method" ], "SendMessage" )
130
131
self .assertEqual (
131
132
span .attributes [SpanAttributes .MESSAGING_SYSTEM ], "aws.sqs"
132
133
)
You can’t perform that action at this time.
0 commit comments