Skip to content

fix: Align OpenTelemetry attribute coverage with database-spans semconv - #32

Merged
chmodas merged 1 commit into
trunkfrom
fix-metric-attrs
May 4, 2026
Merged

fix: Align OpenTelemetry attribute coverage with database-spans semconv#32
chmodas merged 1 commit into
trunkfrom
fix-metric-attrs

Conversation

@chmodas

@chmodas chmodas commented May 4, 2026

Copy link
Copy Markdown
Owner

The db.client.operation.duration histogram previously carried only connection-level attributes (db.system.name, db.namespace). Annotation-derived attributes (db.operation.name, db.collection.name, db.query.summary, db.stored_procedure.name) and error-path attributes (error.type, plus db.response.status_code for sqlx::Error::Database) are now appended to metric_attrs in lock-step with the span attribute set, so dashboards can slice DB latency by operation verb, target collection, or error class – the dimensions OTel's database-spans semconv recommends. InstrumentedStream gains a single-error latch so streams that yield multiple Err items before terminating cannot append duplicate error.type / db.response.status_code keys.

Three additional attributes from the OTel database-spans recommended set now surface on every span and per-operation metric: db.client.connection.pool.name (previously only on the db.client.connection.count gauge; now on every span and the rest of the db.client.connection.* family via the shared connection-attribute set), network.protocol.name (per-backend default via the new Database::DEFAULT_NETWORK_PROTOCOL_NAME constant; overridable via PoolBuilder::with_network_protocol_name), and network.transport (set explicitly via PoolBuilder::with_network_transport; the wrapper does not infer transport from the connect string).

@codecov-commenter

codecov-commenter commented May 4, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.95%. Comparing base (edc9e30) to head (df763be).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk      #32      +/-   ##
==========================================
+ Coverage   99.90%   99.95%   +0.05%     
==========================================
  Files          12       12              
  Lines        2034     2164     +130     
==========================================
+ Hits         2032     2163     +131     
+ Misses          2        1       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The `db.client.operation.duration` histogram previously carried only
connection-level attributes (`db.system.name`, `db.namespace`).
Annotation-derived attributes (`db.operation.name`, `db.collection.name`,
`db.query.summary`, `db.stored_procedure.name`) and error-path attributes
(`error.type`, plus `db.response.status_code` for `sqlx::Error::Database`) are
now appended to `metric_attrs` in lock-step with the span attribute set, so
dashboards can slice DB latency by operation verb, target collection, or error
class – the dimensions OTel's database-spans semconv recommends.
`InstrumentedStream` gains a single-error latch so streams that yield multiple
`Err` items before terminating cannot append duplicate `error.type` /
`db.response.status_code` keys.

Three additional attributes from the OTel database-spans recommended set now
surface on every span and per-operation metric: `db.client.connection.pool.name`
(previously only on the `db.client.connection.count` gauge; now on every span
and the rest of the `db.client.connection.*` family via the shared
connection-attribute set), `network.protocol.name` (per-backend default via the
new `Database::DEFAULT_NETWORK_PROTOCOL_NAME` constant; overridable via
`PoolBuilder::with_network_protocol_name`), and `network.transport` (set
explicitly via `PoolBuilder::with_network_transport`; the wrapper does not infer
transport from the connect string).
@chmodas
chmodas force-pushed the fix-metric-attrs branch from 721a541 to df763be Compare May 4, 2026 14:33
@chmodas
chmodas merged commit 32dd1d5 into trunk May 4, 2026
2 checks passed
@chmodas
chmodas deleted the fix-metric-attrs branch May 4, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants