Skip to content

feat(db): Distinguish async vs sync database drivers using db.driver attribute#5711

Open
harryautomazione wants to merge 4 commits intogetsentry:masterfrom
harryautomazione:feature/db-driver
Open

feat(db): Distinguish async vs sync database drivers using db.driver attribute#5711
harryautomazione wants to merge 4 commits intogetsentry:masterfrom
harryautomazione:feature/db-driver

Conversation

@harryautomazione
Copy link

Description

Adds db.driver attribute to database spans in sqlalchemy and asyncpg integrations to allow distinguishing between async and sync executions.

Fixes #5463

Why

In performance dashboards or logs, all DB spans appear generically (op: db). This makes it hard to identify when an application accidentally triggers blocking sync DB calls inside an async loop (eg. FastAPI).

How

  • SQLAlchemy Integration: Inside _set_db_data, uses conn.engine.dialect.driver (e.g., aiosqlite, asyncpg, psycopg2).
  • AsyncPG Integration: Directly sets db.driver to "asyncpg".

Verification Details

Verified locally using an async SQLAlchemy context where the attribute db.driver was successfully populated with "aiosqlite".

Checklist

@harryautomazione harryautomazione requested a review from a team as a code owner March 19, 2026 14:33
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (asgi) Add option to disable suppressing chained exceptions by alexander-alderman-webb in #5714
  • (db) Distinguish async vs sync database drivers using db.driver attribute by harryautomazione in #5711
  • (logging) Separate ignore lists for events/breadcrumbs and sentry logs by sl0thentr0py in #5698

Bug Fixes 🐛

Anthropic

  • Set exception info on streaming span when applicable by alexander-alderman-webb in #5683
  • Patch AsyncStream.close() and AsyncMessageStream.close() to finish spans by alexander-alderman-webb in #5675
  • Patch Stream.close() and MessageStream.close() to finish spans by alexander-alderman-webb in #5674

Documentation 📚

  • Add note on AI PRs to CONTRIBUTING.md by sentrivana in #5696

Internal Changes 🔧

  • Add -latest alias for each integration test suite by sentrivana in #5706
  • Use date-based branch names for toxgen PRs by sentrivana in #5704
  • 🤖 Update test matrix with new releases (03/19) by github-actions in #5703
  • Add client report tests for span streaming by sentrivana in #5677

Other

  • Update CHANGELOG.md by sentrivana in #5685

🤖 This preview updates automatically when you update the PR.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@alexander-alderman-webb
Copy link
Contributor

Currently blocked by convention approval: #5463 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Distinguish async vs sync database drivers in Python DB spans (FastAPI / SQLAlchemy / asyncpg)

2 participants