Releases: chmodas/sqlx-otel
Releases · chmodas/sqlx-otel
v0.3.0
Added
db.client.response.affected_rowshistogram – a custom metric (no OTel semconv equivalent) mirroring the existingdb.response.affected_rowsspan attribute. Recorded onexecute()calls; carries the same connection / annotation / error attribute set as the duration histogram so dashboards can slice mutation throughput by the same dimensions (#33).PoolBuilder::with_network_protocol_nameandwith_network_transportbuilder methods, plus a per-backendDatabase::DEFAULT_NETWORK_PROTOCOL_NAMEconstant (Postgres →"postgresql", MySQL →"mysql", SQLite →None).network.protocol.name,network.transport, anddb.client.connection.pool.namenow surface on every span and per-operation metric data point so dashboards can slice query latency by the same dimensions OTel's database-spans semconv recommends (#32).
Changed
db.client.connection.pool.namepreviously appeared only on thedb.client.connection.countgauge; it now also propagates to spans, thedb.client.operation.duration/db.client.response.returned_rowshistograms, and the rest of thedb.client.connection.*family via the shared connection-attribute set. Thecountgauge's attribute set is unchanged (#32).db.query.textnow collapses inter-token whitespace runs to a single space and trims leading/trailing whitespace for bothQueryTextMode::Full(default) andQueryTextMode::Obfuscated. Whitespace inside string literals, quoted identifiers, dollar-quoted bodies, and comments is preserved verbatim. Multi-line SQL written for source-level readability now renders as a single readable line in OTel exports without the embedded\nand indentation runs that came from source-level formatting.QueryTextMode::Offis unchanged (#34).
Fixed
- Query-side
with_annotations/with_operationnow compile insideSend-required async contexts (axum handlers,tokio::spawn,tower::Service-bounded futures). TheAnnotatedQuery::fetch_*/executeforwarders were rewritten fromasync fnintofn -> impl Future + Send + 'e, so the HRTB carried by the internalIntoAnnotatedExecutorimpls no longer leaks into auto-trait inference of an opaque coroutine. Span output is byte-identical to the executor-side surface; metrics emission is unchanged by construction because both surfaces continue to funnel through the sameAnnotated<'_, Pool<DB>>Executorimpl (#31). db.client.operation.durationhistogram now carries annotation-derived attributes (db.operation.name,db.collection.name,db.query.summary,db.stored_procedure.name) and error-path attributes (error.type, plusdb.response.status_codeforsqlx::Error::Database). Previously only connection-level attributes (db.system.name,db.namespace) reached the histogram, so dashboards could not slice DB latency by operation verb, target collection, or error class. TheInstrumentedStreampoll loop also gains a single-error latch so streams that yield multipleErritems before terminating cannot append duplicateerror.type/db.response.status_codekeys (#32).
v0.2.0
Added
- Query-side
with_annotations/with_operationvia the newQueryAnnotateExttrait onsqlx::query,sqlx::query_as, andsqlx::query_scalar, so per-query attributes can sit next to the query text.bindandwith_annotationscompose in either order (#22). Query::map/Query::try_mapchains and thesqlx::query!()/query_as!()/query_scalar!()macros now supportwith_annotations/with_operation. On hand-written chains the annotation may sit beforebind, betweenbindandmap, or aftermap; macro queries carry annotations after the macro returns (#23).
Changed
- BREAKING: Sealed the
Databasetrait. Onlysqlx::Sqlite,sqlx::Postgres, andsqlx::MySqlcan implement it; downstream crates cannot. In practice the trait was already constrained to these three backends because it requires an upstreamsqlx::Databaseimpl, but the bound is now enforced at the type level (#25).
v0.1.0
Added
- Span name follows the OpenTelemetry Database Spans § Name hierarchy in full:
db.query.summary(set viaQueryAnnotations::query_summary()) takes precedence over the{operation} {collection}synthesis (#18). - Obfuscation mode for
db.query.text:QueryTextMode::Obfuscatednow replaces string, numeric, hex, boolean, and dollar-quoted literals with?while preserving comments, identifiers, operators, andNULL(#16). - Per-query annotation API for the semantic convention attributes the library cannot derive from SQL:
db.operation.name,db.collection.name,db.query.summary,db.stored_procedure.name(#15). db.response.affected_rowsrecorded onexecute()spans (#13).- Connection pool metrics (
db.client.connection.count,db.client.connection.idle.max, etc.) with a runtime abstraction overtokioandasync-std(#12). - MySQL backend (#6).
- PostgreSQL backend (#4).
- SQLite backend (#3).
- Backend-agnostic instrumentation core:
Pool,PoolBuilder,Transaction,PoolConnection, and theExecutortrait wiring that emits OpenTelemetry-native spans and metrics following the database calls and systems semantic conventions (#2).