zuul/zuul
James E. Blair 8c2433a2c4
Tracing: implement span save/restore
This adds methods to allow us to save and restore spans using
ZooKeeper data.

Additionally, we subclass the tracing.Span class so that we can
transparently handle timestamps which are stored as floating point
numbers rather than integer nanoseconds.

To exercise the new features, emit spans for QueueItems and BuildSets.

Because most of our higher-level (parent) spans may start on
one host and end on another, we save the full information about
the span in ZK and restore it whenever we do anything with it,
including starting child spans.  This works well for starting
a Build span given a BuildSet, since both objects are used by
the executor client and so the span information for both is
available.

However, there are cases where we would like to have child spans
and we do not have the full information of the parent, such as
any children of the Build span on the executor.  We could
duplicate all the information of the Build span in ZK and send
it along with the build request, but we really only need a few
bits of info to start a remote child span.  In OpenTelemetry,
this is called trace propogation, and there are some tools for
this which assume that the implicit trace context is being used
and formats information for an HTTP header.  We could use those
methods, but this change adds a simpler API that is well suited
to our typical json-serialization method of propogation.

To use it, we will add a small extra dictionary to build and merge
requests.  This should serialize to about 104 bytes.

So that we can transparantly handle upgrades from having no
saved state for spans and span context in our ZK data, have our
tracing API return a NonRecordingSpan when we try to restore
from a None value.  This code uses tracing.INVALID_SPAN or
tracing.INVALID_SPAN_CONTEXT which are suitable constants.  They
are sufficiently real for the purpose of context managers, etc.

The only down side is that any child spans of these will be
real, actual reported spans, so in these cases, we will emit
what we intend to be child spans as actual parent traces.
Since this should only happen when a user first enables tracing
on an already existing system, that seems like a reasonable
trade-off.  As new objects are populated, the spans will be emitted
as expected.

The trade off here is that our operational code can be much
simpler as we can avoid null value checks and any confusion regarding
context managers.

In particular, we can just assume that tracing spans and contexts
are always valid.

Change-Id: If55b06572b5e95f8c21611b2a3c23f7fd224a547
2022-09-19 08:42:28 +02:00
..
ansible Merge "Add Ansible 6" 2022-09-08 21:30:00 +00:00
cmd Strictly sequence reconfiguration events 2022-07-18 10:51:59 -07:00
connection Fix read-only branches error in zuul-web 2022-07-04 11:35:36 +02:00
driver Merge "Add option to include returned data in MQTT reporter" 2022-09-16 03:24:34 +00:00
execution_context Add wrapper driver execution context 2017-08-18 16:35:12 -07:00
executor Don't run cleanup playbooks after setup failure 2022-09-07 10:41:37 +02:00
lib Tracing: implement span save/restore 2022-09-19 08:42:28 +02:00
manager Tracing: implement span save/restore 2022-09-19 08:42:28 +02:00
merger Set remote URL after config was updated 2022-08-18 10:34:40 +02:00
reporter Merge "Add config-error reporter and report config errors to DB" 2022-08-31 23:40:06 +00:00
source Add support for GHE repository cache 2022-05-05 13:39:41 -07:00
sphinx docs: remove zuuldocs domain 2020-08-04 16:10:09 +10:00
trigger Filter events on event connection 2021-04-24 08:39:03 -07:00
vendor Add some pipeline processing stats 2022-01-25 08:16:52 -08:00
web Fix links for jobs with special characters 2022-08-23 13:21:25 +02:00
zk Merge "Reduce redundant Gerrit queries" 2022-08-19 21:33:58 +00:00
__init__.py Initial commit. 2012-05-29 14:49:32 -07:00
_setup_hook.py Revert "Revert "Create zuul/web/static on demand"" 2020-07-07 19:53:33 +02:00
change_matcher.py Fix reporting certain config syntax errors 2022-04-26 11:02:17 -07:00
configloader.py Merge "Add nodeset alternatives" 2022-09-16 16:52:44 +00:00
exceptions.py Handle jwt decoding error, fix exception default messages 2022-05-12 18:48:19 +02:00
model_api.py Add nodeset alternatives 2022-09-08 13:01:28 -07:00
model.py Tracing: implement span save/restore 2022-09-19 08:42:28 +02:00
nodepool.py Report gross/total tenant resource usage stats 2022-03-17 14:51:18 +01:00
scheduler.py Add support for configuring and testing tracing 2022-09-19 08:42:28 +02:00
version.py Store version information in component registry 2021-10-20 17:17:02 +02:00