2525
2626from opentelemetry import trace
2727from opentelemetry .instrumentation .redis import RedisInstrumentor
28- from opentelemetry .semconv .trace import (
28+ from opentelemetry .semconv ._incubating .attributes .db_attributes import (
29+ DB_REDIS_DATABASE_INDEX ,
30+ DB_SYSTEM ,
2931 DbSystemValues ,
32+ )
33+ from opentelemetry .semconv ._incubating .attributes .net_attributes import (
34+ NET_PEER_NAME ,
35+ NET_PEER_PORT ,
36+ NET_TRANSPORT ,
3037 NetTransportValues ,
31- SpanAttributes ,
3238)
3339from opentelemetry .test .test_base import TestBase
3440from opentelemetry .trace import SpanKind
@@ -257,18 +263,14 @@ def test_attributes_default(self):
257263
258264 span = spans [0 ]
259265 self .assertEqual (
260- span .attributes [SpanAttributes . DB_SYSTEM ],
266+ span .attributes [DB_SYSTEM ],
261267 DbSystemValues .REDIS .value ,
262268 )
269+ self .assertEqual (span .attributes [DB_REDIS_DATABASE_INDEX ], 0 )
270+ self .assertEqual (span .attributes [NET_PEER_NAME ], "localhost" )
271+ self .assertEqual (span .attributes [NET_PEER_PORT ], 6379 )
263272 self .assertEqual (
264- span .attributes [SpanAttributes .DB_REDIS_DATABASE_INDEX ], 0
265- )
266- self .assertEqual (
267- span .attributes [SpanAttributes .NET_PEER_NAME ], "localhost"
268- )
269- self .assertEqual (span .attributes [SpanAttributes .NET_PEER_PORT ], 6379 )
270- self .assertEqual (
271- span .attributes [SpanAttributes .NET_TRANSPORT ],
273+ span .attributes [NET_TRANSPORT ],
272274 NetTransportValues .IP_TCP .value ,
273275 )
274276
@@ -283,18 +285,14 @@ def test_attributes_tcp(self):
283285
284286 span = spans [0 ]
285287 self .assertEqual (
286- span .attributes [SpanAttributes . DB_SYSTEM ],
288+ span .attributes [DB_SYSTEM ],
287289 DbSystemValues .REDIS .value ,
288290 )
291+ self .assertEqual (span .attributes [DB_REDIS_DATABASE_INDEX ], 1 )
292+ self .assertEqual (span .attributes [NET_PEER_NAME ], "1.1.1.1" )
293+ self .assertEqual (span .attributes [NET_PEER_PORT ], 6380 )
289294 self .assertEqual (
290- span .attributes [SpanAttributes .DB_REDIS_DATABASE_INDEX ], 1
291- )
292- self .assertEqual (
293- span .attributes [SpanAttributes .NET_PEER_NAME ], "1.1.1.1"
294- )
295- self .assertEqual (span .attributes [SpanAttributes .NET_PEER_PORT ], 6380 )
296- self .assertEqual (
297- span .attributes [SpanAttributes .NET_TRANSPORT ],
295+ span .attributes [NET_TRANSPORT ],
298296 NetTransportValues .IP_TCP .value ,
299297 )
300298
@@ -311,18 +309,16 @@ def test_attributes_unix_socket(self):
311309
312310 span = spans [0 ]
313311 self .assertEqual (
314- span .attributes [SpanAttributes . DB_SYSTEM ],
312+ span .attributes [DB_SYSTEM ],
315313 DbSystemValues .REDIS .value ,
316314 )
315+ self .assertEqual (span .attributes [DB_REDIS_DATABASE_INDEX ], 3 )
317316 self .assertEqual (
318- span .attributes [SpanAttributes .DB_REDIS_DATABASE_INDEX ], 3
319- )
320- self .assertEqual (
321- span .attributes [SpanAttributes .NET_PEER_NAME ],
317+ span .attributes [NET_PEER_NAME ],
322318 "/path/to/socket.sock" ,
323319 )
324320 self .assertEqual (
325- span .attributes [SpanAttributes . NET_TRANSPORT ],
321+ span .attributes [NET_TRANSPORT ],
326322 NetTransportValues .OTHER .value ,
327323 )
328324
0 commit comments