Skip to content

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

Merged
merged 7 commits into from
Nov 24, 2020

Conversation

srikanthccv
Copy link
Member

Fixes #209

@srikanthccv srikanthccv requested review from a team, codeboten and ocelotl and removed request for a team November 24, 2020 05:27
@srikanthccv
Copy link
Member Author

cc @lzchen @NathanielRN

Copy link
Contributor

@NathanielRN NathanielRN left a 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!

Comment on lines 25 to 29
db = conn_kwargs.get("db", 0)
if db == 0:
attributes["db.name"] = db
else:
attributes["db.redis.database_index"] = db
Copy link
Contributor

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.

Suggested change
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.

Copy link
Member Author

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.

Copy link
Contributor

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):
Copy link
Contributor

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.

@lzchen lzchen merged commit dabd2f2 into open-telemetry:master Nov 24, 2020
@srikanthccv srikanthccv deleted the dbindex-redis branch December 5, 2020 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add database_index attribute for redis instrumentation when db is not 0
3 participants