You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: instrument the database engine, not the global dispatcher
The DB spans this PR added did not deliver what it claimed. Verified against
a live backend: one API request produced 13 sqlalchemy connect spans and zero
query spans, with no db.statement anywhere. Connection-pool noise dressed up
as database visibility.
Langflow builds an AsyncEngine, and the instrumentor patches the sync engine
underneath it. instrument_dependencies() was called from the app factory with
no engine, because the engine does not exist that early, so SQLAlchemy
instrumented globally and attached to pool events only.
Instrument where the engine is built instead, passing it. Renamed to
instrument_database, and the engine argument is required rather than optional:
the engine-less call is exactly the broken configuration, and a global
instrument() would also win the race and make a later engine-specific call a
silent no-op.
Same request after the change: 28 query spans carrying db.statement, bound
parameters still placeholders, and the flow's input text absent from the trace.
The unit tests passed throughout. They assert the scope is allowlisted and the
instrumentor is wired, not that a query span reaches an exporter, so this was
only visible against a real backend.
0 commit comments