@@ -204,7 +204,7 @@ class StreamedSpan:
204204
205205 __slots__ = (
206206 "name" ,
207- "attributes " ,
207+ "_attributes " ,
208208 "_span_id" ,
209209 "_trace_id" ,
210210 "parent_span_id" ,
@@ -250,7 +250,7 @@ def __init__(
250250 self ._scope = scope
251251
252252 self .name : str = name
253- self .attributes : "Attributes" = attributes or {}
253+ self ._attributes : "Attributes" = attributes or {}
254254
255255 self ._trace_id = trace_id
256256 self .parent_span_id = parent_span_id
@@ -318,7 +318,7 @@ def __enter__(self) -> "StreamedSpan":
318318 "span_id" : self .span_id ,
319319 "parent_span_id" : self .parent_span_id ,
320320 "parent_sampled" : self .parent_sampled ,
321- "attributes" : self .attributes ,
321+ "attributes" : self ._attributes ,
322322 }
323323 custom_sampling_context = (
324324 scope .get_active_propagation_context ()._custom_sampling_context
@@ -432,21 +432,21 @@ def _end(
432432 self ._finished = True
433433
434434 def get_attributes (self ) -> "Attributes" :
435- return self .attributes
435+ return self ._attributes
436436
437437 def set_attribute (self , key : str , value : "AttributeValue" ) -> None :
438- self .attributes [key ] = format_attribute (value )
438+ self ._attributes [key ] = format_attribute (value )
439+
440+ def set_attributes (self , attributes : "Attributes" ) -> None :
441+ for key , value in attributes .items ():
442+ self .set_attribute (key , value )
439443
440444 def remove_attribute (self , key : str ) -> None :
441445 try :
442- del self .attributes [key ]
446+ del self ._attributes [key ]
443447 except KeyError :
444448 pass
445449
446- def set_attributes (self , attributes : "Attributes" ) -> None :
447- for key , value in attributes .items ():
448- self .set_attribute (key , value )
449-
450450 def set_status (self , status : "Union[SpanStatus, str]" ) -> None :
451451 if isinstance (status , Enum ):
452452 status = status .value
0 commit comments