sdk/metrics: copy attributes dict to prevent post-recording mutation (#5106)
* sdk/metrics: copy attributes dict in consume_measurement to prevent mutation When a caller retains a reference to the attributes dict passed to counter.add() (or any instrument record/add call), mutating that dict after the call would silently corrupt the attributes stored on the aggregation and subsequently on exported data points. The fix copies the dict at the point where it is first stored as the canonical attributes for a new aggregation bucket, so downstream mutations by the caller have no effect. Fixes #4610 * fix changelog link to point to PR instead of issue * Apply suggestion from @xrmx * Create 5106.fixed * Apply suggestion from @xrmx --------- Co-authored-by: tejasae-afk <tejasae-afk@users.noreply.github.com> Co-authored-by: Mike Goldsmith <goldsmith.mike@gmail.com> Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
T
Tejas Attarde committed
1d69bd2eaa02715ecf3877a8f391678be58f2f57
Parent: 990a611
Committed by GitHub <noreply@github.com>
on 5/15/2026, 2:10:36 PM