Skip to content

Commit

Permalink
update events and links
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Xue committed May 20, 2020
1 parent 9d3e2d9 commit 0e4a3f1
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ class Span(trace_api.Span):
this `Span`.
"""

# Initialize these lazily assuming most spans won't have them.
_empty_events = BoundedList(MAX_NUM_EVENTS)
_empty_links = BoundedList(MAX_NUM_LINKS)

def __init__(
self,
name: str,
Expand Down Expand Up @@ -295,15 +291,15 @@ def __init__(
)

if events is None:
self.events = Span._empty_events
self.events = BoundedList(MAX_NUM_EVENTS)
else:
self.events = BoundedList(MAX_NUM_EVENTS)
for event in events:
self._filter_attribute_values(event.attributes)
self.events.append(event)

if links is None:
self.links = Span._empty_links
self.links = BoundedList(MAX_NUM_LINKS)
else:
self.links = BoundedList.from_seq(MAX_NUM_LINKS, links)

Expand Down Expand Up @@ -438,9 +434,7 @@ def _add_event(self, event: EventBase) -> None:
if not self.is_recording_events():
return
has_ended = self.end_time is not None
if not has_ended:
if self.events is Span._empty_events:
self.events = BoundedList(MAX_NUM_EVENTS)

if has_ended:
logger.warning("Calling add_event() on an ended span.")
return
Expand Down

0 comments on commit 0e4a3f1

Please sign in to comment.