28
28
)
29
29
30
30
from opentelemetry .instrumentation .boto import BotoInstrumentor
31
- from opentelemetry .sdk .resources import Resource
32
31
from opentelemetry .test .test_base import TestBase
33
32
34
33
@@ -71,12 +70,8 @@ def test_ec2_client(self):
71
70
span = spans [1 ]
72
71
self .assertEqual (span .attributes ["aws.operation" ], "RunInstances" )
73
72
assert_span_http_status_code (span , 200 )
74
- self .assertEqual (
75
- span .resource ,
76
- Resource (
77
- attributes = {"endpoint" : "ec2" , "http_method" : "runinstances" }
78
- ),
79
- )
73
+ self .assertEqual (span .attributes ["endpoint" ], "ec2" )
74
+ self .assertEqual (span .attributes ["http_method" ], "runinstances" )
80
75
self .assertEqual (span .attributes ["http.method" ], "POST" )
81
76
self .assertEqual (span .attributes ["aws.region" ], "us-west-2" )
82
77
self .assertEqual (span .name , "ec2.command" )
@@ -147,10 +142,8 @@ def test_s3_client(self):
147
142
self .assertEqual (len (spans ), 3 )
148
143
span = spans [2 ]
149
144
assert_span_http_status_code (span , 200 )
150
- self .assertEqual (
151
- span .resource ,
152
- Resource (attributes = {"endpoint" : "s3" , "http_method" : "head" }),
153
- )
145
+ self .assertEqual (span .attributes ["endpoint" ], "s3" )
146
+ self .assertEqual (span .attributes ["http_method" ], "head" )
154
147
self .assertEqual (span .attributes ["http.method" ], "HEAD" )
155
148
self .assertEqual (span .attributes ["aws.operation" ], "head_bucket" )
156
149
self .assertEqual (span .name , "s3.command" )
@@ -162,10 +155,8 @@ def test_s3_client(self):
162
155
spans = self .memory_exporter .get_finished_spans ()
163
156
assert spans
164
157
span = spans [2 ]
165
- self .assertEqual (
166
- span .resource ,
167
- Resource (attributes = {"endpoint" : "s3" , "http_method" : "head" }),
168
- )
158
+ self .assertEqual (spans [2 ].attributes ["endpoint" ], "s3" )
159
+ self .assertEqual (spans [2 ].attributes ["http_method" ], "head" )
169
160
170
161
@mock_s3_deprecated
171
162
def test_s3_put (self ):
@@ -182,24 +173,18 @@ def test_s3_put(self):
182
173
self .assertEqual (len (spans ), 3 )
183
174
self .assertEqual (spans [0 ].attributes ["aws.operation" ], "create_bucket" )
184
175
assert_span_http_status_code (spans [0 ], 200 )
185
- self .assertEqual (
186
- spans [0 ].resource ,
187
- Resource (attributes = {"endpoint" : "s3" , "http_method" : "put" }),
188
- )
176
+ self .assertEqual (spans [0 ].attributes ["endpoint" ], "s3" )
177
+ self .assertEqual (spans [0 ].attributes ["http_method" ], "put" )
189
178
# get bucket
190
179
self .assertEqual (spans [1 ].attributes ["aws.operation" ], "head_bucket" )
191
- self .assertEqual (
192
- spans [1 ].resource ,
193
- Resource (attributes = {"endpoint" : "s3" , "http_method" : "head" }),
194
- )
180
+ self .assertEqual (spans [1 ].attributes ["endpoint" ], "s3" )
181
+ self .assertEqual (spans [1 ].attributes ["http_method" ], "head" )
195
182
# put object
196
183
self .assertEqual (
197
184
spans [2 ].attributes ["aws.operation" ], "_send_file_internal"
198
185
)
199
- self .assertEqual (
200
- spans [2 ].resource ,
201
- Resource (attributes = {"endpoint" : "s3" , "http_method" : "put" }),
202
- )
186
+ self .assertEqual (spans [2 ].attributes ["endpoint" ], "s3" )
187
+ self .assertEqual (spans [2 ].attributes ["http_method" ], "put" )
203
188
204
189
@mock_lambda_deprecated
205
190
def test_unpatch (self ):
@@ -239,10 +224,8 @@ def test_lambda_client(self):
239
224
self .assertEqual (len (spans ), 2 )
240
225
span = spans [0 ]
241
226
assert_span_http_status_code (span , 200 )
242
- self .assertEqual (
243
- span .resource ,
244
- Resource (attributes = {"endpoint" : "lambda" , "http_method" : "get" }),
245
- )
227
+ self .assertEqual (span .attributes ["endpoint" ], "lambda" )
228
+ self .assertEqual (span .attributes ["http_method" ], "get" )
246
229
self .assertEqual (span .attributes ["http.method" ], "GET" )
247
230
self .assertEqual (span .attributes ["aws.region" ], "us-east-2" )
248
231
self .assertEqual (span .attributes ["aws.operation" ], "list_functions" )
@@ -256,15 +239,8 @@ def test_sts_client(self):
256
239
spans = self .memory_exporter .get_finished_spans ()
257
240
assert spans
258
241
span = spans [0 ]
259
- self .assertEqual (
260
- span .resource ,
261
- Resource (
262
- attributes = {
263
- "endpoint" : "sts" ,
264
- "http_method" : "getfederationtoken" ,
265
- }
266
- ),
267
- )
242
+ self .assertEqual (span .attributes ["endpoint" ], "sts" )
243
+ self .assertEqual (span .attributes ["http_method" ], "getfederationtoken" )
268
244
self .assertEqual (span .attributes ["aws.region" ], "us-west-2" )
269
245
self .assertEqual (
270
246
span .attributes ["aws.operation" ], "GetFederationToken"
@@ -288,7 +264,5 @@ def test_elasticache_client(self):
288
264
spans = self .memory_exporter .get_finished_spans ()
289
265
assert spans
290
266
span = spans [0 ]
291
- self .assertEqual (
292
- span .resource , Resource (attributes = {"endpoint" : "elasticcache" })
293
- )
267
+ self .assertEqual (span .attributes ["endpoint" ], "elasticcache" )
294
268
self .assertEqual (span .attributes ["aws.region" ], "us-west-2" )
0 commit comments