-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redis instrumentation breaks when host value is not present in the connection kwargs #389
Comments
@eexwhyzee Thanks for reporting. Feel free to send a PR that extracts the host attribute defensively. |
Why do they do it? We certainly don't want instrumentations to break when something is missing but I was wondering Is it possible to not have both (host, port) and (path) in connection kwargs? |
cool cool, i can try to get a PR out sometime this week
I haven't asked the folks over at |
Instrumentations keep getting updated to make sure they follow semantic conventions(until they become stable) and database sem conv suggest they should have at least one of |
cool cool, thanks for the additional context! My initial thought for changes were along the lines of: def _extract_conn_attributes(conn_kwargs):
""" Transform redis conn info into dict """
attributes = {
"db.system": "redis",
}
db = conn_kwargs.get("db", 0)
attributes["db.name"] = db
attributes["db.redis.database_index"] = db
if "path" in conn_kwargs:
attributes["net.peer.name"] = conn_kwargs["path"]
attributes["net.transport"] = "Unix"
else:
attributes["net.peer.name"] = conn_kwargs.get("host", "localhost")
attributes["net.peer.port"] = conn_kwargs.get("port", 6379)
attributes["net.transport"] = "IP.TCP"
return attributes however for #304, seems like its a redis sentinel specific thing where it does not include either |
This issue was marked stale due to lack of activity. It will be closed in 30 days. |
Recently upgraded from
0.11b0
to0.19b0
and having issues getting the redis instrumentation to work with the fakeredis package that is being currently used to mock redis for testing.It appears that the
host
value in the connection kwargs is not preserved in thefakeredis
implementation (they explicitly remove it in their code) and is causing the tests to break.Previously the tests were passing fine with
0.11b0
since it looks like the connection info is just omitted if they were not found.Was wondering if _extract_conn_attributes can be a little bit more forgiving if the values aren't found? For instance, i was able to get the tests passing after i made slight changes to the
_extract_conn_attributes
function to have a default value if thehost
key was not found.Thanks for any help in advance, and also willing to submit a PR if needed!
Describe your environment
Steps to reproduce
failing test:
redis connection kwargs vs fakeredis connection kwargs:
What is the expected behavior?
What did you expect to see?
What is the actual behavior?
What did you see instead?
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: