Store parent span context with span info
Change-Id: Idb9b673542c2054f7bbae094ad5702a472197fe1
This commit is contained in:
parent
13790e2444
commit
bbe89422e7
@ -195,11 +195,11 @@ class TestTracing(ZuulTestCase):
|
||||
self.log.debug("Received:\n%s", merge_job)
|
||||
build = self.getSpan('Build')
|
||||
self.log.debug("Received:\n%s", build)
|
||||
job = self.getSpan('JobExecution')
|
||||
self.log.debug("Received:\n%s", job)
|
||||
jobexec = self.getSpan('JobExecution')
|
||||
self.log.debug("Received:\n%s", jobexec)
|
||||
self.assertEqual(item.trace_id, buildset.trace_id)
|
||||
self.assertEqual(item.trace_id, build.trace_id)
|
||||
self.assertNotEqual(item.span_id, job.span_id)
|
||||
self.assertNotEqual(item.span_id, jobexec.span_id)
|
||||
self.assertTrue(buildset.start_time_unix_nano >=
|
||||
item.start_time_unix_nano)
|
||||
self.assertTrue(buildset.end_time_unix_nano <=
|
||||
@ -208,6 +208,14 @@ class TestTracing(ZuulTestCase):
|
||||
buildset.start_time_unix_nano)
|
||||
self.assertTrue(merge_job.end_time_unix_nano <=
|
||||
buildset.end_time_unix_nano)
|
||||
self.assertEqual(jobexec.parent_span_id,
|
||||
build.span_id)
|
||||
self.assertEqual(build.parent_span_id,
|
||||
buildset.span_id)
|
||||
self.assertEqual(merge_job.parent_span_id,
|
||||
buildset.span_id)
|
||||
self.assertEqual(buildset.parent_span_id,
|
||||
item.span_id)
|
||||
item_attrs = attributes_to_dict(item.attributes)
|
||||
self.assertTrue(item_attrs['ref_number'] == "1")
|
||||
self.assertTrue(item_attrs['ref_patchset'] == "1")
|
||||
|
@ -67,12 +67,19 @@ def getSpanInfo(span, include_attributes=False):
|
||||
for l in span.links]
|
||||
attrs = _formatAttributes(span.attributes)
|
||||
context = span.get_span_context()
|
||||
parent_context = None
|
||||
if span.parent:
|
||||
parent_context = {
|
||||
**_formatContext(span.parent),
|
||||
"is_remote": span.parent.is_remote,
|
||||
}
|
||||
ret = {
|
||||
'name': span.name,
|
||||
'trace_id': context.trace_id,
|
||||
'span_id': context.span_id,
|
||||
'trace_flags': context.trace_flags,
|
||||
'start_time': span.start_time,
|
||||
'parent': parent_context,
|
||||
}
|
||||
if links:
|
||||
ret['links'] = links
|
||||
@ -119,11 +126,18 @@ def restoreSpan(span_info, is_remote=True):
|
||||
link = trace.Link(link_context, link_info['attributes'])
|
||||
links.append(link)
|
||||
attributes = span_info.get('attributes', {})
|
||||
parent_context = None
|
||||
if parent_info := span_info.get("parent"):
|
||||
parent_context = trace.SpanContext(
|
||||
parent_info['trace_id'],
|
||||
parent_info['span_id'],
|
||||
is_remote=parent_info['is_remote'],
|
||||
)
|
||||
|
||||
span = ZuulSpan(
|
||||
name=span_info['name'],
|
||||
context=span_context,
|
||||
parent=None,
|
||||
parent=parent_context,
|
||||
sampler=tracer.sampler,
|
||||
resource=tracer.resource,
|
||||
attributes=attributes,
|
||||
|
Loading…
x
Reference in New Issue
Block a user