feat(integrations): Add integration for aiomysql#4703
feat(integrations): Add integration for aiomysql#4703tonal wants to merge 20 commits intogetsentry:masterfrom
aiomysql#4703Conversation
aiomysql
|
Hey @tonal thanks for the PR, great work! Could you address the cursor comments above? |
aiomysqlaiomysql
sentry_sdk/integrations/aiomysql.py
Outdated
| """ | ||
| Adapted from module sentry_sdk.integrations.asyncpg | ||
| """ |
There was a problem hiding this comment.
Hi @tonal ,
Thanks for the contribution, much appreciated!
Can you add unit tests for the integration as well? You can probably adapt them from the asyncpg tests.
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Integrations
Other
Bug Fixes 🐛Anthropic
Pydantic Ai
Other
Internal Changes 🔧Litellm
Other
Other
🤖 This preview updates automatically when you update the PR. |
Rewrite the aiomysql integration to fix issues raised in PR getsentry#4703: - Patch Cursor.execute and Cursor.executemany instead of Connection.query - Make _wrap_connect async (await inside span context) - Handle bytes/bytearray queries from executemany's internal batching - Normalize query text using " ".join(query.split()) for performance - Protect _sentry_skip_next_execute flag with try/finally to prevent leakage - Remove dead _wrap_cursor and unused _record context manager Add 17 end-to-end tests covering connect, execute, executemany, record_params, cursor iteration, connection pools, query source, span origin, and normalization. Update CI configuration: tox.ini envlist, GitHub Actions workflow with MySQL service container, and test suite config. Co-Authored-By: Qwen Code <noreply@anthropic.com> Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Add AioMySQLIntegration to _AUTO_ENABLING_INTEGRATIONS and _MIN_VERSIONS (fixes sentry bot: auto-enabling and minimum version check) - Protect _sentry_skip_next_execute flag with try/finally in _wrap_executemany and do NOT reset it in _wrap_execute (fixes cursor bot: flag resets prematurely on non-INSERT row-by-row fallback) - Normalize query text using " ".join(query.split()) instead of re.sub for performance - Fix duplicate YAML keys bug in test_group.jinja template that caused postgres service to be silently dropped when mysql service is added - Add test for non-INSERT executemany (row-by-row fallback) Co-Authored-By: Qwen Code <noreply@anthropic.com> Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
# Conflicts: # .github/workflows/test-integrations-dbs.yml # sentry_sdk/integrations/aiomysql.py # tests/integrations/aiomysql/test_aiomysql.py
The leftover {% if needs_mysql %} block created duplicate 'services:' and
'env:' keys, causing YAML parsers to silently overwrite earlier definitions.
Co-Authored-By: Qwen Code <noreply@anthropic.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
…ction Fixes sentry bot review comment on PR getsentry#4703. Co-Authored-By: Qwen Code <noreply@anthropic.com> Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
|
@antonpirker All cursor comments are now addressed! Here is a summary of all the fixes:
@alexander-alderman-webb |
…tional args Fixes cursor bot comment: positional args to aiomysql.connect are now captured correctly for span metadata. Co-Authored-By: Qwen Code <noreply@anthropic.com> Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Run ruff format on aiomysql.py to satisfy lint checks - Add cryptography to aiomysql tox deps (required for MySQL 8.0 caching_sha2_password authentication in CI) Co-Authored-By: Qwen Code <noreply@anthropic.com> Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
…d reconnects - Patch Connection._connect instead of aiomysql.connect so that pool.py (which imports connect directly from .connection) and reconnects are all instrumented. - Connection._connect has no arguments beyond self; read host/port/db/user directly from connection properties. - Add assertions to test_connection_pool verifying connect spans are created for each pooled connection. - Use `is not None` checks in _set_db_data to avoid skipping falsy but valid values (fixes cursor bot comment). - Suppress MySQL warnings in test fixture via warnings.catch_warnings(). - Replace deprecated enable_tracing=True with traces_sample_rate=1.0 in tests. Co-Authored-By: Qwen Code <noreply@anthropic.com> Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6e05b78. Configure here.
… guards Address cursor bot comment: CONNECT WRAPPER LACKS NULL GUARDS. Replace direct span.set_data calls with _set_db_data(span, self) to reuse the same getattr/is-not-None logic used for query spans. Co-Authored-By: Qwen Code <noreply@anthropic.com> Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

Add support for aiomysql to the SDK.