Docs/Integrate/OpenTelemetry
OSS

OpenTelemetry

DBLift emits OpenTelemetry spans for its operations, driven off the event bus. It depends only on opentelemetry-api: your application owns the SDK and the exporter. Traces only — no metrics are emitted.

extra · dblift[otel]

Install

pip install "dblift[otel]"

Instrument a client

trace_migrate.py

python
from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider trace.set_tracer_provider(TracerProvider()) # configure your exporter here from dblift.api import DBLiftClient from dblift.integrations.opentelemetry import instrument client = DBLiftClient.from_sqlalchemy(engine, migrations_dir="migrations") handle = instrument(client) # opt-in, per client client.migrate() # emits dblift.migrate + dblift.script spans handle.uninstrument() # detach the listeners

Spans

SpanEmitted by
dblift.migratemigrate(), with one dblift.script child per script
dblift.undoundo(), also with dblift.script children
dblift.cleanclean()
dblift.baselinebaseline()
dblift.repairrepair()
dblift.validatevalidate()
dblift.infoinfo()

Attributes are prefixed dblift. — operation, target_version, version, script, description, type, count, success_count, failure_count, dry_run and execution_time — and the engine is recorded as db.system. A failed operation sets the span status to ERROR with the reported message.

Nesting

Spans attach to the current OTel context, so inside a traced web request the DBLift spans nest under the request span automatically.

Telemetry never breaks a release

Listener errors are swallowed and logged at debug level, and a span left open by an unusual error path is closed as ERROR so nesting stays correct.

On this page