10
10
)
11
11
12
12
from opentelemetry .ext .botocore import BotocoreInstrumentor
13
+ from opentelemetry .sdk .resources import Resource
13
14
from opentelemetry .test .test_base import TestBase
14
15
15
16
@@ -49,7 +50,12 @@ def test_traced_client(self):
49
50
self .assertEqual (span .attributes ["aws.region" ], "us-west-2" )
50
51
self .assertEqual (span .attributes ["aws.operation" ], "DescribeInstances" )
51
52
assert_span_http_status_code (span , 200 )
52
- self .assertEqual (span .resource , "ec2.describeinstances" )
53
+ self .assertEqual (
54
+ span .resource ,
55
+ Resource (
56
+ labels = {"endpoint" : "ec2" , "operation" : "describeinstances" }
57
+ ),
58
+ )
53
59
self .assertEqual (span .name , "ec2.command" )
54
60
55
61
@mock_ec2
@@ -73,7 +79,10 @@ def test_s3_client(self):
73
79
self .assertEqual (len (spans ), 2 )
74
80
self .assertEqual (span .attributes ["aws.operation" ], "ListBuckets" )
75
81
assert_span_http_status_code (span , 200 )
76
- self .assertEqual (span .resource , "s3.listbuckets" )
82
+ self .assertEqual (
83
+ span .resource ,
84
+ Resource (labels = {"endpoint" : "s3" , "operation" : "listbuckets" }),
85
+ )
77
86
78
87
# testing for span error
79
88
self .memory_exporter .get_finished_spans ()
@@ -82,7 +91,10 @@ def test_s3_client(self):
82
91
spans = self .memory_exporter .get_finished_spans ()
83
92
assert spans
84
93
span = spans [2 ]
85
- self .assertEqual (span .resource , "s3.listobjects" )
94
+ self .assertEqual (
95
+ span .resource ,
96
+ Resource (labels = {"endpoint" : "s3" , "operation" : "listobjects" }),
97
+ )
86
98
87
99
@mock_s3
88
100
def test_s3_put (self ):
@@ -97,9 +109,15 @@ def test_s3_put(self):
97
109
self .assertEqual (len (spans ), 2 )
98
110
self .assertEqual (span .attributes ["aws.operation" ], "CreateBucket" )
99
111
assert_span_http_status_code (span , 200 )
100
- self .assertEqual (span .resource , "s3.createbucket" )
112
+ self .assertEqual (
113
+ span .resource ,
114
+ Resource (labels = {"endpoint" : "s3" , "operation" : "createbucket" }),
115
+ )
101
116
self .assertEqual (spans [1 ].attributes ["aws.operation" ], "PutObject" )
102
- self .assertEqual (spans [1 ].resource , "s3.putobject" )
117
+ self .assertEqual (
118
+ spans [1 ].resource ,
119
+ Resource (labels = {"endpoint" : "s3" , "operation" : "putobject" }),
120
+ )
103
121
self .assertEqual (spans [1 ].attributes ["params.Key" ], str (params ["Key" ]))
104
122
self .assertEqual (
105
123
spans [1 ].attributes ["params.Bucket" ], str (params ["Bucket" ])
@@ -119,7 +137,10 @@ def test_sqs_client(self):
119
137
self .assertEqual (span .attributes ["aws.region" ], "us-east-1" )
120
138
self .assertEqual (span .attributes ["aws.operation" ], "ListQueues" )
121
139
assert_span_http_status_code (span , 200 )
122
- self .assertEqual (span .resource , "sqs.listqueues" )
140
+ self .assertEqual (
141
+ span .resource ,
142
+ Resource (labels = {"endpoint" : "sqs" , "operation" : "listqueues" }),
143
+ )
123
144
124
145
@mock_kinesis
125
146
def test_kinesis_client (self ):
@@ -136,7 +157,12 @@ def test_kinesis_client(self):
136
157
self .assertEqual (span .attributes ["aws.region" ], "us-east-1" )
137
158
self .assertEqual (span .attributes ["aws.operation" ], "ListStreams" )
138
159
assert_span_http_status_code (span , 200 )
139
- self .assertEqual (span .resource , "kinesis.liststreams" )
160
+ self .assertEqual (
161
+ span .resource ,
162
+ Resource (
163
+ labels = {"endpoint" : "kinesis" , "operation" : "liststreams" }
164
+ ),
165
+ )
140
166
141
167
@mock_kinesis
142
168
def test_unpatch (self ):
@@ -176,7 +202,12 @@ def test_lambda_client(self):
176
202
self .assertEqual (span .attributes ["aws.region" ], "us-east-1" )
177
203
self .assertEqual (span .attributes ["aws.operation" ], "ListFunctions" )
178
204
assert_span_http_status_code (span , 200 )
179
- self .assertEqual (span .resource , "lambda.listfunctions" )
205
+ self .assertEqual (
206
+ span .resource ,
207
+ Resource (
208
+ labels = {"endpoint" : "lambda" , "operation" : "listfunctions" }
209
+ ),
210
+ )
180
211
181
212
@mock_kms
182
213
def test_kms_client (self ):
@@ -191,7 +222,10 @@ def test_kms_client(self):
191
222
self .assertEqual (span .attributes ["aws.region" ], "us-east-1" )
192
223
self .assertEqual (span .attributes ["aws.operation" ], "ListKeys" )
193
224
assert_span_http_status_code (span , 200 )
194
- self .assertEqual (span .resource , "kms.listkeys" )
225
+ self .assertEqual (
226
+ span .resource ,
227
+ Resource (labels = {"endpoint" : "kms" , "operation" : "listkeys" }),
228
+ )
195
229
196
230
# checking for protection on sts against security leak
197
231
self .assertTrue ("params" not in span .attributes .keys ())
0 commit comments