28
28
_PoolAcquireContextManager ,
29
29
)
30
30
from opentelemetry .sdk import resources
31
- from opentelemetry .semconv .trace import SpanAttributes
31
+ from opentelemetry .semconv ._incubating .attributes .db_attributes import (
32
+ DB_NAME ,
33
+ DB_STATEMENT ,
34
+ DB_SYSTEM ,
35
+ DB_USER ,
36
+ )
37
+ from opentelemetry .semconv ._incubating .attributes .net_attributes import (
38
+ NET_PEER_NAME ,
39
+ NET_PEER_PORT ,
40
+ )
32
41
from opentelemetry .test .test_base import TestBase
33
42
34
43
@@ -317,24 +326,16 @@ def test_span_succeeded(self):
317
326
self .assertEqual (span .name , "Test" )
318
327
self .assertIs (span .kind , trace_api .SpanKind .CLIENT )
319
328
320
- self .assertEqual (
321
- span .attributes [SpanAttributes .DB_SYSTEM ], "testcomponent"
322
- )
323
- self .assertEqual (
324
- span .attributes [SpanAttributes .DB_NAME ], "testdatabase"
325
- )
326
- self .assertEqual (
327
- span .attributes [SpanAttributes .DB_STATEMENT ], "Test query"
328
- )
329
+ self .assertEqual (span .attributes [DB_SYSTEM ], "testcomponent" )
330
+ self .assertEqual (span .attributes [DB_NAME ], "testdatabase" )
331
+ self .assertEqual (span .attributes [DB_STATEMENT ], "Test query" )
329
332
self .assertEqual (
330
333
span .attributes ["db.statement.parameters" ],
331
334
"('param1Value', False)" ,
332
335
)
333
- self .assertEqual (span .attributes [SpanAttributes .DB_USER ], "testuser" )
334
- self .assertEqual (
335
- span .attributes [SpanAttributes .NET_PEER_NAME ], "testhost"
336
- )
337
- self .assertEqual (span .attributes [SpanAttributes .NET_PEER_PORT ], 123 )
336
+ self .assertEqual (span .attributes [DB_USER ], "testuser" )
337
+ self .assertEqual (span .attributes [NET_PEER_NAME ], "testhost" )
338
+ self .assertEqual (span .attributes [NET_PEER_PORT ], 123 )
338
339
self .assertIs (span .status .status_code , trace_api .StatusCode .UNSET )
339
340
340
341
def test_span_not_recording (self ):
@@ -381,9 +382,7 @@ def test_span_failed(self):
381
382
spans_list = self .memory_exporter .get_finished_spans ()
382
383
self .assertEqual (len (spans_list ), 1 )
383
384
span = spans_list [0 ]
384
- self .assertEqual (
385
- span .attributes [SpanAttributes .DB_STATEMENT ], "Test query"
386
- )
385
+ self .assertEqual (span .attributes [DB_STATEMENT ], "Test query" )
387
386
self .assertIs (span .status .status_code , trace_api .StatusCode .ERROR )
388
387
self .assertEqual (
389
388
span .status .description , "ProgrammingError: Test Exception"
@@ -400,9 +399,7 @@ def test_executemany(self):
400
399
401
400
self .assertEqual (len (spans_list ), 1 )
402
401
span = spans_list [0 ]
403
- self .assertEqual (
404
- span .attributes [SpanAttributes .DB_STATEMENT ], "Test query"
405
- )
402
+ self .assertEqual (span .attributes [DB_STATEMENT ], "Test query" )
406
403
407
404
def test_callproc (self ):
408
405
db_integration = AiopgIntegration (self .tracer , "testcomponent" )
@@ -416,7 +413,7 @@ def test_callproc(self):
416
413
self .assertEqual (len (spans_list ), 1 )
417
414
span = spans_list [0 ]
418
415
self .assertEqual (
419
- span .attributes [SpanAttributes . DB_STATEMENT ],
416
+ span .attributes [DB_STATEMENT ],
420
417
"Test stored procedure" ,
421
418
)
422
419
0 commit comments