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_SYSTEM ,
30+ DB_REDIS_DATABASE_INDEX ,
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)
39+
3340from opentelemetry .test .test_base import TestBase
3441from opentelemetry .trace import SpanKind
3542
@@ -257,18 +264,18 @@ def test_attributes_default(self):
257264
258265 span = spans [0 ]
259266 self .assertEqual (
260- span .attributes [SpanAttributes . DB_SYSTEM ],
267+ span .attributes [DB_SYSTEM ],
261268 DbSystemValues .REDIS .value ,
262269 )
263270 self .assertEqual (
264- span .attributes [SpanAttributes . DB_REDIS_DATABASE_INDEX ], 0
271+ span .attributes [DB_REDIS_DATABASE_INDEX ], 0
265272 )
266273 self .assertEqual (
267- span .attributes [SpanAttributes . NET_PEER_NAME ], "localhost"
274+ span .attributes [NET_PEER_NAME ], "localhost"
268275 )
269- self .assertEqual (span .attributes [SpanAttributes . NET_PEER_PORT ], 6379 )
276+ self .assertEqual (span .attributes [NET_PEER_PORT ], 6379 )
270277 self .assertEqual (
271- span .attributes [SpanAttributes . NET_TRANSPORT ],
278+ span .attributes [NET_TRANSPORT ],
272279 NetTransportValues .IP_TCP .value ,
273280 )
274281
@@ -283,18 +290,18 @@ def test_attributes_tcp(self):
283290
284291 span = spans [0 ]
285292 self .assertEqual (
286- span .attributes [SpanAttributes . DB_SYSTEM ],
293+ span .attributes [DB_SYSTEM ],
287294 DbSystemValues .REDIS .value ,
288295 )
289296 self .assertEqual (
290- span .attributes [SpanAttributes . DB_REDIS_DATABASE_INDEX ], 1
297+ span .attributes [DB_REDIS_DATABASE_INDEX ], 1
291298 )
292299 self .assertEqual (
293- span .attributes [SpanAttributes . NET_PEER_NAME ], "1.1.1.1"
300+ span .attributes [NET_PEER_NAME ], "1.1.1.1"
294301 )
295- self .assertEqual (span .attributes [SpanAttributes . NET_PEER_PORT ], 6380 )
302+ self .assertEqual (span .attributes [NET_PEER_PORT ], 6380 )
296303 self .assertEqual (
297- span .attributes [SpanAttributes . NET_TRANSPORT ],
304+ span .attributes [NET_TRANSPORT ],
298305 NetTransportValues .IP_TCP .value ,
299306 )
300307
@@ -311,18 +318,18 @@ def test_attributes_unix_socket(self):
311318
312319 span = spans [0 ]
313320 self .assertEqual (
314- span .attributes [SpanAttributes . DB_SYSTEM ],
321+ span .attributes [DB_SYSTEM ],
315322 DbSystemValues .REDIS .value ,
316323 )
317324 self .assertEqual (
318- span .attributes [SpanAttributes . DB_REDIS_DATABASE_INDEX ], 3
325+ span .attributes [DB_REDIS_DATABASE_INDEX ], 3
319326 )
320327 self .assertEqual (
321- span .attributes [SpanAttributes . NET_PEER_NAME ],
328+ span .attributes [NET_PEER_NAME ],
322329 "/path/to/socket.sock" ,
323330 )
324331 self .assertEqual (
325- span .attributes [SpanAttributes . NET_TRANSPORT ],
332+ span .attributes [NET_TRANSPORT ],
326333 NetTransportValues .OTHER .value ,
327334 )
328335
0 commit comments