-
Notifications
You must be signed in to change notification settings - Fork 111
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
cassandra-driver Instrumentation #1280
base: main
Are you sure you want to change the base?
Conversation
🦙 MegaLinter status: ✅ SUCCESS
See detailed report in MegaLinter reports |
85611c7
to
7d5ea09
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1280 +/- ##
==========================================
- Coverage 81.28% 81.25% -0.03%
==========================================
Files 201 202 +1
Lines 22174 22223 +49
Branches 3519 3526 +7
==========================================
+ Hits 18024 18058 +34
- Misses 2982 2993 +11
- Partials 1168 1172 +4 ☔ View full report in Codecov by Sentry. |
d2fe1f3
to
676ad40
Compare
13c3265
to
369e2c3
Compare
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.
Just a couple minor things - otherwise looks good! Marking it as pre-approved cause I don't think any of them are merge stoppers.
# the result. We can therefore just instrument execute_async() and achieve full sync/async coverage. | ||
# If this changes in the future we'll need an additional wrapper, but care should be taken not to double wrap. | ||
wrap_function_wrapper(module, "Session.execute_async", wrap_Session_execute_async) | ||
wrap_function_wrapper(module, "Session.execute", wrap_Session_execute_async) # TODO check this |
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.
Should we remove this wrapper then given the above comment about only needing to wrap execute_async
?
# Exit early there's no transaction, or if we're under an existing DatabaseTrace | ||
return wrapped(*args, **kwargs) | ||
|
||
bound_args = bind_args(wrapped, args, kwargs) |
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.
So glad we made this-I use it all the time now!
sql = bound_args.get("query", None) | ||
if not isinstance(sql, str): | ||
statement = getattr(sql, "prepared_statement", sql) # Unbind BoundStatement | ||
sql = statement.query_string # Unpack query from SimpleStatement and PreparedStatement |
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.
Should we use a getattr here in case this attribute doesn't exist?
|
||
database_name = getattr(instance, "keyspace", None) | ||
|
||
# hosts = instance.cluster.metadata.all_hosts() |
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.
# hosts = instance.cluster.metadata.all_hosts() |
database_name = getattr(instance, "keyspace", None) | ||
|
||
# hosts = instance.cluster.metadata.all_hosts() | ||
# breakpoint() |
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.
# breakpoint() |
): | ||
return wrapped(*args, **kwargs) | ||
|
||
return wrapped(*args, **kwargs) |
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.
Is this reachable?
# Cassandra isn't DBAPI2 compliant, but we need the DatabaseTrace to function properly. We can set parameters | ||
# for CQL parsing and the product name here, and leave the explain plan functionality unused. | ||
global DBAPI2_MODULE | ||
DBAPI2_MODULE = module |
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.
This is a little unorthodox but seems like it will work fine.
Overview
cassandra-driver
library.