Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions docs/platforms/python/integrations/aiomysql/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
title: aiomysql
description: "Learn about importing the aiomysql integration and how it captures queries from aiomysql as spans."
---

The aiomysql integration captures queries from [aiomysql](https://github.com/aio-libs/aiomysql/) as spans.

## Install

Install `sentry-sdk` from PyPI:

```bash {tabTitle:pip}
pip install sentry-sdk
```
```bash {tabTitle:uv}
uv add sentry-sdk
```

## Configure

Add `AioMySQLIntegration()` to your `integrations` list:

```python
import sentry_sdk
from sentry_sdk.integrations.aiomysql import AioMySQLIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# Add data like inputs and responses;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
integrations=[
AioMySQLIntegration(),
],
)
```

## Verify

```python
import sentry_sdk
from sentry_sdk.integrations.aiomysql import AioMySQLIntegration
import aiomysql
import asyncio

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
traces_sample_rate=1.0,
send_default_pii=True,
integrations=[
AioMySQLIntegration(),
],
)

async def main():
conn = await aiomysql.connect(
host="localhost",
port=3306,
user="root",
password="root",
db="test",
)
try:
with sentry_sdk.start_transaction(name="testing_sentry"):
async with conn.cursor() as cur:
await cur.execute("SELECT 'Hello World'")
result = await cur.fetchone()
finally:
conn.close()

asyncio.run(main())
```

This will create a transaction called `testing_sentry` in the Performance section of [sentry.io](https://sentry.io) and will create a span for the `SELECT` statement.

It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).

## Supported Versions

- aiomysql: 0.3+

<Include name="python-use-older-sdk-for-legacy-support.mdx" />
1 change: 1 addition & 0 deletions docs/platforms/python/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra

| | **Auto-enabled** |
| -------------------------------------------------------------------------------------------------------------------------------------- | :--------------: |
| <LinkWithPlatformIcon platform="python.aiomysql" label="aiomysql" url="/platforms/python/integrations/aiomysql" /> | |
| <LinkWithPlatformIcon platform="python.asyncpg" label="asyncpg" url="/platforms/python/integrations/asyncpg" /> | ✓ |
| <LinkWithPlatformIcon platform="python.clickhouse-driver" label="ClickHouse" url="/platforms/python/integrations/clickhouse-driver" /> | ✓ |
| <LinkWithPlatformIcon platform="python.pymongo" label="MongoDB" url="/platforms/python/integrations/pymongo" /> | ✓ |
Expand Down
Loading