From 59b225fbf397cdac3b92c3953b6d4b7f29abfb94 Mon Sep 17 00:00:00 2001 From: Camillo Date: Wed, 15 Jan 2025 10:17:01 -0800 Subject: [PATCH] Change set_attributes to take a Mapping (#4374) --- opentelemetry-api/src/opentelemetry/trace/span.py | 4 ++-- opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/opentelemetry-api/src/opentelemetry/trace/span.py b/opentelemetry-api/src/opentelemetry/trace/span.py index 325bb9064a..6e54dfc721 100644 --- a/opentelemetry-api/src/opentelemetry/trace/span.py +++ b/opentelemetry-api/src/opentelemetry/trace/span.py @@ -79,7 +79,7 @@ def get_span_context(self) -> "SpanContext": @abc.abstractmethod def set_attributes( - self, attributes: typing.Dict[str, types.AttributeValue] + self, attributes: typing.Mapping[str, types.AttributeValue] ) -> None: """Sets Attributes. @@ -529,7 +529,7 @@ def end(self, end_time: typing.Optional[int] = None) -> None: pass def set_attributes( - self, attributes: typing.Dict[str, types.AttributeValue] + self, attributes: typing.Mapping[str, types.AttributeValue] ) -> None: pass diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py index 2e4448387c..ec5bc3f0fe 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py @@ -30,6 +30,7 @@ Dict, Iterator, List, + Mapping, MutableMapping, Optional, Sequence, @@ -842,7 +843,7 @@ def get_span_context(self): return self._context def set_attributes( - self, attributes: Dict[str, types.AttributeValue] + self, attributes: Mapping[str, types.AttributeValue] ) -> None: with self._lock: if self._end_time is not None: