Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_attribute(self, key: str, value: types.AttributeValue) -> None:
with self._lock:
if not self.is_recording_events():
return
has_ended = self.end_time is not None
if not has_ended:
if self.attributes is Span.empty_attributes:
self.attributes = BoundedDict(MAX_NUM_ATTRIBUTES)
if has_ended:
logger.warning("Setting attribute on ended span.")
return
self.attributes[key] = value
self.name = name
self.context = context
self.parent = parent
self.sampler = sampler
self.trace_config = trace_config
self.resource = resource
self.kind = kind
self._set_status_on_exception = set_status_on_exception
self.span_processor = span_processor
self.status = None
self._lock = threading.Lock()
if attributes is None:
self.attributes = Span.empty_attributes
else:
self.attributes = BoundedDict.from_map(
MAX_NUM_ATTRIBUTES, attributes
)
if events is None:
self.events = Span.empty_events
else:
self.events = BoundedList.from_seq(MAX_NUM_EVENTS, events)
if links is None:
self.links = Span.empty_links
else:
self.links = BoundedList.from_seq(MAX_NUM_LINKS, links)
self.end_time = None # type: Optional[int]