Create link to previous buildset span

Create a link to the previous buildset span on gate reset. To make this
work we'll start the buildset span when the buildset is created instead
of only when we set the configuration.

This change also adds the `is_remote` flag of the span context of
related links. This is required for creating a `SpanContext` in order to
deserialize the links.

Change-Id: If3a3a83739c1472659d71d05dcf67f84ddce4247
This commit is contained in:
Simon Westphahl
2022-09-19 14:05:43 +02:00
parent 937e25432f
commit 7d3b186b3d
3 changed files with 26 additions and 13 deletions

View File

@@ -62,6 +62,7 @@ def _formatAttributes(attrs):
def getSpanInfo(span, include_attributes=False):
"""Return a dict for use in serializing a Span."""
links = [{'context': _formatContext(l.context),
'is_remote': l.context.is_remote,
'attributes': _formatAttributes(l.attributes)}
for l in span.links]
attrs = _formatAttributes(span.attributes)
@@ -113,7 +114,8 @@ def restoreSpan(span_info, is_remote=True):
for link_info in span_info.get('links', []):
link_context = trace.SpanContext(
link_info['context']['trace_id'],
link_info['context']['span_id'])
link_info['context']['span_id'],
is_remote=link_info['is_remote'])
link = trace.Link(link_context, link_info['attributes'])
links.append(link)
attributes = span_info.get('attributes', {})