-
Notifications
You must be signed in to change notification settings - Fork 682
Add database_index for redis instrumentation #210
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet thank you for the change! Just some non-blocking comments!
db = conn_kwargs.get("db", 0) | ||
if db == 0: | ||
attributes["db.name"] = db | ||
else: | ||
attributes["db.redis.database_index"] = db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think it's okay to just always set it to db.redis.database_index
after reading the spec.
db = conn_kwargs.get("db", 0) | |
if db == 0: | |
attributes["db.name"] = db | |
else: | |
attributes["db.redis.database_index"] = db | |
attributes["db.redis.database_index"] = conn_kwargs.get("db", 0) |
If we want to do more we can also do db.name
, but I think just this specific attribute is good enough and then let the exporter decide which one to take.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spec says it is conditionally required. May be we can set both db.name
and db.redis.database_index
? Let others also share opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My vote is for both.
super().tearDown() | ||
RedisInstrumentor().uninstrument() | ||
|
||
def _check_span(self, span, name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably an unpopular opinion... but since this is only used once I'd be okay with just putting these checks inline in the test_get
function until someone else needs same code.
But I'm okay with going with the consensus here.
Fixes #209