Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 107 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ derive = ["sqlx-macros/derive"]
macros = ["derive", "sqlx-macros/macros", "sqlx-core/offline", "sqlx-mysql?/offline", "sqlx-postgres?/offline", "sqlx-sqlite?/offline"]
migrate = ["sqlx-core/migrate", "sqlx-macros?/migrate", "sqlx-mysql?/migrate", "sqlx-postgres?/migrate", "sqlx-sqlite?/migrate"]

# Append sqlcommenter trailing comments to outgoing queries on backends that
# support it (PostgreSQL, MySQL — SQLite has no managed observability
# consumer). Pulls trace context from OTel's globally configured propagator
# (typically W3C TraceContext via `tracing-opentelemetry`). When a comment
# is appended, the backend executor routes through the non-cached prepare
# path so the statement cache isn't polluted with one-shot entries.
sqlcommenter = ["sqlx-core/sqlcommenter", "sqlx-mysql?/sqlcommenter", "sqlx-postgres?/sqlcommenter"]

# Enable parsing of `sqlx.toml` for configuring macros and migrations.
sqlx-toml = ["sqlx-core/sqlx-toml", "sqlx-macros?/sqlx-toml", "sqlx-sqlite?/sqlx-toml"]

Expand Down
15 changes: 15 additions & 0 deletions sqlx-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ sqlx-toml = ["serde", "toml/parse"]

_unstable-doc = ["sqlx-toml"]

# Append a sqlcommenter-style trailing comment to each query sent to the
# database, sourcing trace context from OTel's globally configured
# `TextMapPropagator` (typically W3C TraceContext, yielding `traceparent` and
# `tracestate`). Lets server-side observability tools (Cloud SQL Insights,
# AlloyDB Insights, etc.) correlate query stats with upstream traces.
# Requires the user's app to have a propagator registered (otherwise no
# comment is emitted).
#
# Note: when a comment is appended, the backend executor routes through the
# non-cached prepare path so we don't fill the statement cache with one-shot
# entries. Same wire round-trips, no cache pollution.
sqlcommenter = ["dep:opentelemetry", "dep:tracing-opentelemetry"]

[dependencies]
# Runtimes
async-global-executor = { workspace = true, optional = true }
Expand Down Expand Up @@ -96,6 +109,8 @@ sha2 = { version = "0.10.0", default-features = false, optional = true }
#sqlformat = "0.2.0"
tokio-stream = { version = "0.1.8", features = ["fs"], optional = true }
tracing = { version = "0.1.37", features = ["log"] }
opentelemetry = { version = "0.30", default-features = false, features = ["trace"], optional = true }
tracing-opentelemetry = { version = "0.31", default-features = false, optional = true }
smallvec = "1.13.1"
url = { version = "2.2.2" }
bstr = { version = "1.0.1", default-features = false, features = ["std"], optional = true }
Expand Down
1 change: 1 addition & 0 deletions sqlx-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub mod query_as;
pub mod query_builder;
pub mod query_scalar;
pub mod sql_str;
pub mod sqlcommenter;

pub mod raw_sql;
pub mod row;
Expand Down
Loading