-
Notifications
You must be signed in to change notification settings - Fork 214
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
include rows_affected
count in dbapi2 instrumentations
#614
Conversation
affected_rows
count in dbapi2 instrumentationsrows_affected
count in dbapi2 instrumentations
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.
nice!
return method(sql, params) | ||
result = method(sql, params) | ||
# store "rows affected", but only for insert/update/delete | ||
if span and self.rowcount not in (-1, None) and signature[:6] in DML_QUERIES: |
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 extract 6
to the top of the file, and compute it from the lengths of the strings in DML_QUERIES
? we might end up adding additional dialect-specific statement types
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.
yeah, this seemed like a cute little optimization at the time ("oh look, all 3 keywords are 6 characters long, nice!"), but probably not worth the hassle. I'll modify to signature.startswith(DML_QUERIES)
, which, funny story, according to timeit
is about 10% faster ¯\_(ツ)_/¯.
But you bring up an interesting point regarding dialects. DML_QUERIES
should probably live on the CursorProxy
, so that driver-specific subclasses can override it.
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.
Hah :)
Sounds good to me.
# Conflicts: # CHANGELOG.md # elasticapm/traces.py # tests/instrumentation/pymssql_tests.py
💚 Build SucceededExpand to view the summary
Build stats
Test stats 🧪
|
* include `rows_affected` count in dbapi2 instrumentations fixes elastic#613 * fix tests * only capture `rows_affected` for INSERT/UPDATE/DELETE queries * use `startswith(DML_QUERIES)` instead of relying on all keywords being 6 characters * update changelog
* include `rows_affected` count in dbapi2 instrumentations fixes elastic#613 * fix tests * only capture `rows_affected` for INSERT/UPDATE/DELETE queries * use `startswith(DML_QUERIES)` instead of relying on all keywords being 6 characters * update changelog
* include `rows_affected` count in dbapi2 instrumentations fixes elastic#613 * fix tests * only capture `rows_affected` for INSERT/UPDATE/DELETE queries * use `startswith(DML_QUERIES)` instead of relying on all keywords being 6 characters * update changelog
fixes #613
depends on elastic/apm-server#2802