Skip to content

Commit be2c578

Browse files
committed
Fix net peer attribute for unix socket connection
1 parent 1ee7261 commit be2c578

File tree

1 file changed

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

1 file changed

+6
-6
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ def _extract_conn_attributes(conn_kwargs):
2929
}
3030
db = conn_kwargs.get("db", 0)
3131
attributes[SpanAttributes.DB_REDIS_DATABASE_INDEX] = db
32-
try:
32+
if "path" in conn_kwargs:
33+
attributes[SpanAttributes.NET_PEER_NAME] = conn_kwargs.get("path", "")
34+
attributes[SpanAttributes.NET_TRANSPORT] = (
35+
NetTransportValues.OTHER.value
36+
)
37+
else:
3338
attributes[SpanAttributes.NET_PEER_NAME] = conn_kwargs.get(
3439
"host", "localhost"
3540
)
@@ -39,11 +44,6 @@ def _extract_conn_attributes(conn_kwargs):
3944
attributes[SpanAttributes.NET_TRANSPORT] = (
4045
NetTransportValues.IP_TCP.value
4146
)
42-
except KeyError:
43-
attributes[SpanAttributes.NET_PEER_NAME] = conn_kwargs.get("path", "")
44-
attributes[SpanAttributes.NET_TRANSPORT] = (
45-
NetTransportValues.OTHER.value
46-
)
4747

4848
return attributes
4949

0 commit comments

Comments
 (0)