2828 _PoolAcquireContextManager ,
2929)
3030from 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+ )
3241from opentelemetry .test .test_base import TestBase
3342
3443
@@ -317,24 +326,16 @@ def test_span_succeeded(self):
317326 self .assertEqual (span .name , "Test" )
318327 self .assertIs (span .kind , trace_api .SpanKind .CLIENT )
319328
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" )
329332 self .assertEqual (
330333 span .attributes ["db.statement.parameters" ],
331334 "('param1Value', False)" ,
332335 )
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 )
338339 self .assertIs (span .status .status_code , trace_api .StatusCode .UNSET )
339340
340341 def test_span_not_recording (self ):
@@ -381,9 +382,7 @@ def test_span_failed(self):
381382 spans_list = self .memory_exporter .get_finished_spans ()
382383 self .assertEqual (len (spans_list ), 1 )
383384 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" )
387386 self .assertIs (span .status .status_code , trace_api .StatusCode .ERROR )
388387 self .assertEqual (
389388 span .status .description , "ProgrammingError: Test Exception"
@@ -400,9 +399,7 @@ def test_executemany(self):
400399
401400 self .assertEqual (len (spans_list ), 1 )
402401 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" )
406403
407404 def test_callproc (self ):
408405 db_integration = AiopgIntegration (self .tracer , "testcomponent" )
@@ -416,7 +413,7 @@ def test_callproc(self):
416413 self .assertEqual (len (spans_list ), 1 )
417414 span = spans_list [0 ]
418415 self .assertEqual (
419- span .attributes [SpanAttributes . DB_STATEMENT ],
416+ span .attributes [DB_STATEMENT ],
420417 "Test stored procedure" ,
421418 )
422419
0 commit comments