opentelemetry-instrumentation-pymysql
OpenTelemetry PyMySQL instrumentation
What it is and what it does
This package is an OpenTelemetry instrumentation plugin that automatically captures tracing data from PyMySQL database connections. When installed and initialized, it hooks into PyMySQL's query execution layer to emit spans for each SQL operation, including query text, execution time, and result metadata. This allows distributed tracing systems to correlate database calls with upstream application requests and other service calls.
The package is part of the OpenTelemetry Python contrib ecosystem and follows the standard instrumentation pattern: it depends on opentelemetry-api for the tracing API, opentelemetry-instrumentation for the base instrumentation framework, and opentelemetry-instrumentation-dbapi for database-specific span generation. It is actively maintained and supports Python 3.10 through 3.14.
Use it for:
- Add database query tracing to a web service to correlate slow SQL with upstream request latency in a distributed system.
- Monitor PyMySQL connection pool behavior and query patterns across microservices using a centralized tracing backend.
- Debug application performance by examining query execution spans alongside application logs and metrics in an observability platform.
- Instrument legacy applications using PyMySQL to gain visibility into database operations without modifying application code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds OpenTelemetry tracing instrumentation to PyMySQL database connections, automatically capturing SQL queries and their execution metrics.
Yes, if you are already using OpenTelemetry in your observability stack and need to trace PyMySQL queries. The low install friction, active maintenance, permissive license, and zero known vulnerabilities make it a straightforward addition. The beta status (0.65b0) is worth noting—verify stability expectations for your use case before production deployment, but the recent release cadence and 1086 GitHub stars suggest it is reasonably mature.
Install
opentelemetry-instrumentation-pymysql on PyPI
pip
pip install opentelemetry-instrumentation-pymysqluv
uv add opentelemetry-instrumentation-pymysqlpoetry
poetry add opentelemetry-instrumentation-pymysqlInstalling opentelemetry-instrumentation-pymysql
Before you install
Low friction installation with a pure-Python wheel. Actively maintained as of 2026-08-14 with recent releases. Depends on three core OpenTelemetry packages (opentelemetry-api, opentelemetry-instrumentation, opentelemetry-instrumentation-dbapi) that are widely used in observability stacks.
License in practice
Apache-2.0 permissive license allows use in commercial and proprietary projects without restriction, though derivative works must retain attribution.
Quickstart
pip install opentelemetry-instrumentation-pymysql
from opentelemetry.instrumentation.pymysql import PyMySQLInstrumentor
PyMySQLInstrumentor().instrument()
Requires Python 3.10 or later; PyMySQL must be installed separately for instrumentation to attach to actual database connections.
Verify before relying
- Whether instrumentation works with PyMySQL versions prior to a specific release or has known compatibility gaps.
- Whether the 0.65b0 beta version is production-ready or if stability issues are documented.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — opentelemetry-api, opentelemetry-instrumentation-dbapi, opentelemetry-instrumentation |
| Maintenance | actively maintained — 29 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,996,097/month — #2,405 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: opentelemetry_instrumentation_pymysql-0.65b0-py3-none-any.whl
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
opentelemetry-instrumentation-mysqlclientAdds OpenTelemetry tracing instrumentation to…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-dbapiAdds automatic tracing and observability…
permissive · top 1,000 on PyPI
opentelemetry-instrumentation-sqlite3Adds OpenTelemetry tracing instrumentation to…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-pymssqlAdds automatic tracing and monitoring of…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-mysqlAdds distributed tracing to MySQL database…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-psycopgAdds OpenTelemetry tracing instrumentation to…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-tortoiseormAdds distributed tracing to Tortoise ORM…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-psycopg2Adds distributed tracing instrumentation to…
permissive · top 1,000 on PyPI
opentelemetry-instrumentation-pymongoAdds automatic tracing and observability…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-sqlalchemyAdds distributed tracing to SQLAlchemy database…
permissive · top 1,000 on PyPI