mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 05:32:30 +08:00
Set database_index when db is not 0
This commit is contained in:
@ -21,8 +21,12 @@ def _extract_conn_attributes(conn_kwargs):
|
|||||||
""" Transform redis conn info into dict """
|
""" Transform redis conn info into dict """
|
||||||
attributes = {
|
attributes = {
|
||||||
"db.system": "redis",
|
"db.system": "redis",
|
||||||
"db.name": conn_kwargs.get("db", 0),
|
|
||||||
}
|
}
|
||||||
|
db = conn_kwargs.get("db", 0)
|
||||||
|
if db == 0:
|
||||||
|
attributes["db.name"] = db
|
||||||
|
else:
|
||||||
|
attributes["db.redis.database_index"] = db
|
||||||
try:
|
try:
|
||||||
attributes["net.peer.name"] = conn_kwargs["host"]
|
attributes["net.peer.name"] = conn_kwargs["host"]
|
||||||
attributes["net.peer.ip"] = conn_kwargs["port"]
|
attributes["net.peer.ip"] = conn_kwargs["port"]
|
||||||
|
Reference in New Issue
Block a user