Monitor SQLAlchemy performance with OpenTelemetry
SQLAlchemy is an Object Relational Mapper for Python that gives application developers the full power and flexibility of SQL.
In this article you will learn how to monitor and optimize SQLAlchemy performance using OpenTelemetry observability framework.
What is OpenTelemetry?
Otel specifies how to collect and export telemetry data in a vendor agnostic way. With OpenTelemetry, you can instrument your application once and then add or change vendors without changing the instrumentation, for example, many open source tracing tools already support OpenTelemetry.
OpenTelemetry is available for most programming languages and provides interoperability across different languages and environments.
To install OpenTelemetry instrumentation for SQLAlchemy:
pip install opentelemetry-instrumentation-sqlalchemy
To instrument sqlalchemy database client:
from sqlalchemy import create_engine from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor engine = create_engine("sqlite:///:memory:") SQLAlchemyInstrumentor().instrument(engine=engine)
What is Uptrace?
Uptrace is an open source APM for OpenTelemetry with an intuitive query builder, rich dashboards, automatic alerts, and integrations for most languages and frameworks.
You can get started with Uptrace by downloading a DEB/RPM package or a pre-compiled Go binary.