When emitting json events, parents were always taken from context if they were not explicitly set. This included cases where parent was explicitly set to None.
Solution
The code now checks whether the event's parent is root (i.e. the event is not inside a span) and if so, no span is included.
Span is also not looked up now in SerializableContext where we already have the current span so we can call scope on it directly. This lead to it being structurally identical to SerializableSpan, but we need a different implementation for Serialize so the two can live next to each other.
Motivation
Closes #2973
When emitting json events, parents were always taken from context if they were not explicitly set. This included cases where parent was explicitly set to
None
.Solution
The code now checks whether the event's parent is root (i.e. the event is not inside a span) and if so, no span is included.
Span is also not looked up now in
SerializableContext
where we already have the current span so we can callscope
on it directly. This lead to it being structurally identical toSerializableSpan
, but we need a different implementation forSerialize
so the two can live next to each other.