|
20 | 20 |
|
21 | 21 | from typing import TYPE_CHECKING, Any |
22 | 22 |
|
| 23 | +from opentelemetry.semconv._incubating.attributes.db_attributes import ( |
| 24 | + DB_REDIS_DATABASE_INDEX, |
| 25 | + DB_SYSTEM, |
| 26 | +) |
| 27 | +from opentelemetry.semconv._incubating.attributes.net_attributes import ( |
| 28 | + NET_PEER_NAME, |
| 29 | + NET_PEER_PORT, |
| 30 | + NET_TRANSPORT, |
| 31 | +) |
23 | 32 | from opentelemetry.semconv.trace import ( |
24 | 33 | DbSystemValues, |
25 | 34 | NetTransportValues, |
26 | | - SpanAttributes, |
27 | 35 | ) |
28 | 36 | from opentelemetry.trace import Span |
29 | 37 |
|
|
41 | 49 | def _extract_conn_attributes(conn_kwargs): |
42 | 50 | """Transform redis conn info into dict""" |
43 | 51 | attributes = { |
44 | | - SpanAttributes.DB_SYSTEM: DbSystemValues.REDIS.value, |
| 52 | + DB_SYSTEM: DbSystemValues.REDIS.value, |
45 | 53 | } |
46 | 54 | db = conn_kwargs.get("db", 0) |
47 | | - attributes[SpanAttributes.DB_REDIS_DATABASE_INDEX] = db |
| 55 | + attributes[DB_REDIS_DATABASE_INDEX] = db |
48 | 56 | if "path" in conn_kwargs: |
49 | | - attributes[SpanAttributes.NET_PEER_NAME] = conn_kwargs.get("path", "") |
50 | | - attributes[SpanAttributes.NET_TRANSPORT] = ( |
51 | | - NetTransportValues.OTHER.value |
52 | | - ) |
| 57 | + attributes[NET_PEER_NAME] = conn_kwargs.get("path", "") |
| 58 | + attributes[NET_TRANSPORT] = NetTransportValues.OTHER.value |
53 | 59 | else: |
54 | | - attributes[SpanAttributes.NET_PEER_NAME] = conn_kwargs.get( |
55 | | - "host", "localhost" |
56 | | - ) |
57 | | - attributes[SpanAttributes.NET_PEER_PORT] = conn_kwargs.get( |
58 | | - "port", 6379 |
59 | | - ) |
60 | | - attributes[SpanAttributes.NET_TRANSPORT] = ( |
61 | | - NetTransportValues.IP_TCP.value |
62 | | - ) |
| 60 | + attributes[NET_PEER_NAME] = conn_kwargs.get("host", "localhost") |
| 61 | + attributes[NET_PEER_PORT] = conn_kwargs.get("port", 6379) |
| 62 | + attributes[NET_TRANSPORT] = NetTransportValues.IP_TCP.value |
63 | 63 |
|
64 | 64 | return attributes |
65 | 65 |
|
|
0 commit comments