|
56 | 56 | HTTP_TARGET, |
57 | 57 | HTTP_URL, |
58 | 58 | ) |
59 | | -from opentelemetry.semconv._incubating.attributes.net_attributes import NET_HOST_PORT |
| 59 | +from opentelemetry.semconv._incubating.attributes.net_attributes import ( |
| 60 | + NET_HOST_PORT, |
| 61 | +) |
60 | 62 | from opentelemetry.semconv.attributes.http_attributes import ( |
61 | 63 | HTTP_REQUEST_METHOD, |
62 | 64 | HTTP_RESPONSE_STATUS_CODE, |
@@ -254,20 +256,15 @@ def test_sub_app_fastapi_call(self): |
254 | 256 | spans_with_http_attributes = [ |
255 | 257 | span |
256 | 258 | for span in spans |
257 | | - if ( |
258 | | - HTTP_URL in span.attributes |
259 | | - or HTTP_TARGET in span.attributes |
260 | | - ) |
| 259 | + if (HTTP_URL in span.attributes or HTTP_TARGET in span.attributes) |
261 | 260 | ] |
262 | 261 |
|
263 | 262 | # We expect only one span to have the HTTP attributes set (the SERVER span from the app itself) |
264 | 263 | # the sub app is not instrumented with manual instrumentation tests. |
265 | 264 | self.assertEqual(1, len(spans_with_http_attributes)) |
266 | 265 |
|
267 | 266 | for span in spans_with_http_attributes: |
268 | | - self.assertEqual( |
269 | | - "/sub/home", span.attributes[HTTP_TARGET] |
270 | | - ) |
| 267 | + self.assertEqual("/sub/home", span.attributes[HTTP_TARGET]) |
271 | 268 | self.assertEqual( |
272 | 269 | "https://testserver:443/sub/home", |
273 | 270 | span.attributes[HTTP_URL], |
@@ -318,19 +315,14 @@ def test_sub_app_fastapi_call(self): |
318 | 315 | spans_with_http_attributes = [ |
319 | 316 | span |
320 | 317 | for span in spans |
321 | | - if ( |
322 | | - HTTP_URL in span.attributes |
323 | | - or HTTP_TARGET in span.attributes |
324 | | - ) |
| 318 | + if (HTTP_URL in span.attributes or HTTP_TARGET in span.attributes) |
325 | 319 | ] |
326 | 320 |
|
327 | 321 | # We now expect spans with attributes from both the app and its sub app |
328 | 322 | self.assertEqual(2, len(spans_with_http_attributes)) |
329 | 323 |
|
330 | 324 | for span in spans_with_http_attributes: |
331 | | - self.assertEqual( |
332 | | - "/sub/home", span.attributes[HTTP_TARGET] |
333 | | - ) |
| 325 | + self.assertEqual("/sub/home", span.attributes[HTTP_TARGET]) |
334 | 326 | self.assertEqual( |
335 | 327 | "https://testserver:443/sub/home", |
336 | 328 | span.attributes[HTTP_URL], |
@@ -391,14 +383,10 @@ def test_fastapi_route_attribute_added(self): |
391 | 383 | self.assertEqual(len(spans), 3) |
392 | 384 | for span in spans: |
393 | 385 | self.assertIn("GET /user/{username}", span.name) |
394 | | - self.assertEqual( |
395 | | - spans[-1].attributes[HTTP_ROUTE], "/user/{username}" |
396 | | - ) |
| 386 | + self.assertEqual(spans[-1].attributes[HTTP_ROUTE], "/user/{username}") |
397 | 387 | # ensure that at least one attribute that is populated by |
398 | 388 | # the asgi instrumentation is successfully feeding though. |
399 | | - self.assertEqual( |
400 | | - spans[-1].attributes[HTTP_FLAVOR], "1.1" |
401 | | - ) |
| 389 | + self.assertEqual(spans[-1].attributes[HTTP_FLAVOR], "1.1") |
402 | 390 |
|
403 | 391 | def test_fastapi_excluded_urls(self): |
404 | 392 | """Ensure that given fastapi routes are excluded.""" |
@@ -1213,19 +1201,14 @@ def test_sub_app_fastapi_call(self): |
1213 | 1201 | spans_with_http_attributes = [ |
1214 | 1202 | span |
1215 | 1203 | for span in spans |
1216 | | - if ( |
1217 | | - HTTP_URL in span.attributes |
1218 | | - or HTTP_TARGET in span.attributes |
1219 | | - ) |
| 1204 | + if (HTTP_URL in span.attributes or HTTP_TARGET in span.attributes) |
1220 | 1205 | ] |
1221 | 1206 |
|
1222 | 1207 | # We now expect spans with attributes from both the app and its sub app |
1223 | 1208 | self.assertEqual(2, len(spans_with_http_attributes)) |
1224 | 1209 |
|
1225 | 1210 | for span in spans_with_http_attributes: |
1226 | | - self.assertEqual( |
1227 | | - "/sub/home", span.attributes[HTTP_TARGET] |
1228 | | - ) |
| 1211 | + self.assertEqual("/sub/home", span.attributes[HTTP_TARGET]) |
1229 | 1212 | self.assertEqual( |
1230 | 1213 | "https://testserver:443/sub/home", |
1231 | 1214 | span.attributes[HTTP_URL], |
@@ -1306,19 +1289,14 @@ def test_sub_app_fastapi_call(self): |
1306 | 1289 | spans_with_http_attributes = [ |
1307 | 1290 | span |
1308 | 1291 | for span in spans |
1309 | | - if ( |
1310 | | - HTTP_URL in span.attributes |
1311 | | - or HTTP_TARGET in span.attributes |
1312 | | - ) |
| 1292 | + if (HTTP_URL in span.attributes or HTTP_TARGET in span.attributes) |
1313 | 1293 | ] |
1314 | 1294 |
|
1315 | 1295 | # We now expect spans with attributes from both the app and its sub app |
1316 | 1296 | self.assertEqual(2, len(spans_with_http_attributes)) |
1317 | 1297 |
|
1318 | 1298 | for span in spans_with_http_attributes: |
1319 | | - self.assertEqual( |
1320 | | - "/sub/home", span.attributes[HTTP_TARGET] |
1321 | | - ) |
| 1299 | + self.assertEqual("/sub/home", span.attributes[HTTP_TARGET]) |
1322 | 1300 | self.assertEqual( |
1323 | 1301 | "https://testserver:443/sub/home", |
1324 | 1302 | span.attributes[HTTP_URL], |
|
0 commit comments