SIGN IN SIGN UP

opentelemetry-sdk: reduce lock contention in attributes (#5298)

* opentelemetry-sdk: reduce lock contention in attributes

There are a few improvements here:
- set_attributes was double locking (once in set_attributes and once in __setitem__. This change updates the call to a private _setitem_locked for set_attributes once the lock has been obtained
- __iter__ doesn't use a lock if the BoundedAttributes's instantiated as immutable
- _worker_awaken was being set even when it's already set, adding a check in emit to avoid unnecessary calls

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>

* move code out of hotpath

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>

* lint

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>

* changelog

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>

* apply feedback, fix lint

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>

* ruff format

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>

---------

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
A
Alex Boten committed
4b4f1ee4bd6fd67e581699e302393cd3f6a8e31b
Parent: 4b5b5ef
Committed by GitHub <noreply@github.com> on 6/16/2026, 8:49:53 PM