summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-09-28 19:38:11 +0000
committerGerrit Code Review <review@openstack.org>2022-09-28 19:38:11 +0000
commit591b0b5da855085f0ae229578c80df761041e87d (patch)
treeb290ee673c8d68a1f72f66a12ce8dc1c01cd6529
parent5cb2801fad8e21c12333e66e34a7081a54ea52f3 (diff)
parent7d3b186b3d71e3f311bb70cb4cff12785ccca412 (diff)
downloadzuul-591b0b5da855085f0ae229578c80df761041e87d.tar.gz
Merge "Create link to previous buildset span"
-rw-r--r--zuul/lib/tracing.py4
-rw-r--r--zuul/manager/__init__.py4
-rw-r--r--zuul/model.py31
3 files changed, 26 insertions, 13 deletions
diff --git a/zuul/lib/tracing.py b/zuul/lib/tracing.py
index 42b2681f3..94a78c5ad 100644
--- a/zuul/lib/tracing.py
+++ b/zuul/lib/tracing.py
@@ -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', {})
diff --git a/zuul/manager/__init__.py b/zuul/manager/__init__.py
index 4cadf5440..8ba3cef14 100644
--- a/zuul/manager/__init__.py
+++ b/zuul/manager/__init__.py
@@ -1359,9 +1359,7 @@ class PipelineManager(metaclass=ABCMeta):
# isn't already set.
tpc = tenant.project_configs.get(item.change.project.canonical_name)
if not build_set.ref:
- with trace.use_span(tracing.restoreSpan(item.span_info)):
- span_info = tracing.startSavedSpan('BuildSet')
- build_set.setConfiguration(self.current_context, span_info)
+ build_set.setConfiguration(self.current_context)
# Next, if a change ahead has a broken config, then so does
# this one. Record that and don't do anything else.
diff --git a/zuul/model.py b/zuul/model.py
index 536e7fecc..32b1cfadf 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -4177,7 +4177,7 @@ class BuildSet(zkobject.ZKObject):
len(self.builds),
self.getStateName(self.merge_state))
- def setConfiguration(self, context, span_info):
+ def setConfiguration(self, context):
with self.activeContext(context):
# The change isn't enqueued until after it's created
# so we don't know what the other changes ahead will be
@@ -4197,7 +4197,6 @@ class BuildSet(zkobject.ZKObject):
self.merger_items = [i.makeMergerItem() for i in items]
self.configured = True
self.configured_time = time.time()
- self.span_info = span_info
def _toChangeDict(self, item):
# Inject bundle_id to dict if available, this can be used to decide
@@ -4399,8 +4398,12 @@ class QueueItem(zkobject.ZKObject):
obj._save(context, data, create=True)
files_state = (BuildSet.COMPLETE if obj.change.files is not None
else BuildSet.NEW)
- obj.updateAttributes(context, current_build_set=BuildSet.new(
- context, item=obj, files_state=files_state))
+
+ with trace.use_span(tracing.restoreSpan(obj.span_info)):
+ buildset_span_info = tracing.startSavedSpan("BuildSet")
+ obj.updateAttributes(context, current_build_set=BuildSet.new(
+ context, item=obj, files_state=files_state,
+ span_info=buildset_span_info))
return obj
def getPath(self):
@@ -4517,11 +4520,21 @@ class QueueItem(zkobject.ZKObject):
old_build_set = self.current_build_set
files_state = (BuildSet.COMPLETE if self.change.files is not None
else BuildSet.NEW)
- self.updateAttributes(
- context,
- current_build_set=BuildSet.new(context, item=self,
- files_state=files_state),
- layout_uuid=None)
+
+ with trace.use_span(tracing.restoreSpan(self.span_info)):
+ old_buildset_span = tracing.restoreSpan(old_build_set.span_info)
+ link = trace.Link(
+ old_buildset_span.get_span_context(),
+ attributes={"previous_buildset": old_build_set.uuid})
+ buildset_span_info = tracing.startSavedSpan(
+ "BuildSet", links=[link])
+
+ self.updateAttributes(
+ context,
+ current_build_set=BuildSet.new(context, item=self,
+ files_state=files_state,
+ span_info=buildset_span_info),
+ layout_uuid=None)
old_build_set.delete(context)
def addBuild(self, build):