skillfed

opentelemetry-instrumentation-pymysql

OpenTelemetry PyMySQL instrumentation

opentelemetry-instrumentation-pymysql v0.65b0 4.0M downloads/30d#2,405 on PyPI1,086
Permissive license Apache-2.0 Active released

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-pymysql

uv

uv add opentelemetry-instrumentation-pymysql

poetry

poetry add opentelemetry-instrumentation-pymysql

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

opentelemetry pymysql tracingdatabase query instrumentationpymysql observabilitysql query tracingmysql connection monitoringopentelemetry dbapi instrumentationdistributed tracing mysql
observabilitytracingdatabase-instrumentation

More Monitoring packages

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

opentelemetry-semantic-conventions

Provides generated Python code for…

permissive · top 100 on PyPI

opentelemetry-sdk

Provides the reference implementation of the…

permissive · top 100 on PyPI

opentelemetry-api

Provides the abstract API and interfaces for…

permissive · top 100 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation-mysqlclient

Adds OpenTelemetry tracing instrumentation to…

permissive · top 5,000 on PyPI

opentelemetry-instrumentation-dbapi

Adds automatic tracing and observability…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation-sqlite3

Adds OpenTelemetry tracing instrumentation to…

permissive · top 5,000 on PyPI

opentelemetry-instrumentation-pymssql

Adds automatic tracing and monitoring of…

permissive · top 15,000 on PyPI

opentelemetry-instrumentation-mysql

Adds distributed tracing to MySQL database…

permissive · top 5,000 on PyPI

opentelemetry-instrumentation-psycopg

Adds OpenTelemetry tracing instrumentation to…

permissive · top 5,000 on PyPI

opentelemetry-instrumentation-tortoiseorm

Adds distributed tracing to Tortoise ORM…

permissive · top 5,000 on PyPI

opentelemetry-instrumentation-psycopg2

Adds distributed tracing instrumentation to…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation-pymongo

Adds automatic tracing and observability…

permissive · top 5,000 on PyPI

opentelemetry-instrumentation-sqlalchemy

Adds distributed tracing to SQLAlchemy database…

permissive · top 1,000 on PyPI