Skip to content

Commit 010df3e

Browse files
authored
Replace SpanAttributes by semconv._incubating.attributes (#3809)
1 parent c1a9f1f commit 010df3e

File tree

1 file changed

+16
-16
lines changed
  • instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis

1 file changed

+16
-16
lines changed

instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/util.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@
2020

2121
from typing import TYPE_CHECKING, Any
2222

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+
)
2332
from opentelemetry.semconv.trace import (
2433
DbSystemValues,
2534
NetTransportValues,
26-
SpanAttributes,
2735
)
2836
from opentelemetry.trace import Span
2937

@@ -41,25 +49,17 @@
4149
def _extract_conn_attributes(conn_kwargs):
4250
"""Transform redis conn info into dict"""
4351
attributes = {
44-
SpanAttributes.DB_SYSTEM: DbSystemValues.REDIS.value,
52+
DB_SYSTEM: DbSystemValues.REDIS.value,
4553
}
4654
db = conn_kwargs.get("db", 0)
47-
attributes[SpanAttributes.DB_REDIS_DATABASE_INDEX] = db
55+
attributes[DB_REDIS_DATABASE_INDEX] = db
4856
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
5359
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
6363

6464
return attributes
6565

0 commit comments

Comments
 (0)