Skip to content

fix(stats): allow WithStatsAttributes to override library defaults#78

Open
obitech wants to merge 1 commit into
mainfrom
obitech/override-default-stats
Open

fix(stats): allow WithStatsAttributes to override library defaults#78
obitech wants to merge 1 commit into
mainfrom
obitech/override-default-stats

Conversation

@obitech
Copy link
Copy Markdown
Member

@obitech obitech commented May 12, 2026

Library defaults were appended after user attrs in recordStats, so any override for db.client.connection.pool.name supplied via WithStatsAttributes was silently dropped by attribute.NewSet's last-value-wins dedup. Seed both defaults (db.system.name and db.client.connection.pool.name) into statsOptions before options are applied so user attrs land at the end of the slice and win on key collision.

Add a regression test using OTel's manual reader that verifies user overrides take effect while non-overridden defaults are preserved.

Ref #71

Library defaults were appended after user attrs in recordStats, so any
override for db.client.connection.pool.name supplied via
WithStatsAttributes was silently dropped by attribute.NewSet's
last-value-wins dedup. Seed both defaults (db.system.name and
db.client.connection.pool.name) into statsOptions before options are
applied so user attrs land at the end of the slice and win on key
collision.

Add a regression test using OTel's manual reader that verifies user
overrides take effect while non-overridden defaults are preserved.
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.

1 participant