-
Notifications
You must be signed in to change notification settings - Fork 599
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
Instrument RedisCluster clients #1177
Instrument RedisCluster clients #1177
Conversation
|
...tion/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py
Outdated
Show resolved
Hide resolved
...tion/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py
Outdated
Show resolved
Hide resolved
...tion/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py
Outdated
Show resolved
Hide resolved
@srikanthccv |
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.
LGTM, Just one more suggestion.
cmds = [ | ||
_format_command_args(c.args if hasattr(c, "args") else c[0]) | ||
for c in command_stack | ||
] | ||
resource = "\n".join(cmds) | ||
|
||
span_name = " ".join([args[0] for args, _ in instance.command_stack]) | ||
span_name = " ".join( | ||
[ | ||
(c.args[0] if hasattr(c, "args") else c[0][0]) | ||
for c in command_stack | ||
] | ||
) |
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 would also suggest to safe guard this code for potential IndexError
s.
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.
updated to handle IndexError
.
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.
updated to handle AttributeError
and IndexError
in one try block.
From the constributing guidelines, would you like to be added as a component owner for the redis instrumentation? |
@@ -149,7 +152,8 @@ def _traced_execute_command(func, instance, args, kwargs): | |||
) as span: | |||
if span.is_recording(): | |||
span.set_attribute(SpanAttributes.DB_STATEMENT, query) | |||
_set_connection_attributes(span, instance) | |||
if hasattr(instance, "connection_pool"): |
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.
Maybe add the hasattr
check in the _set_connection_attributes
function?
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.
moved hasattr
check to the _set_connection_attributes
function.
@lzchen |
Description
This PR adds instrumentation to RedisCluster clients in the Redis library. (redis.cluster.RedisCluster, redis.asyncio.cluster.RedisCluster)
Closes #1167
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
test_redis_functional.py
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.