Trace Git connection events

The connection event span is created when we generate the trigger
events. Contrary to the other drivers there is no pre-processing step
and therefore no span.

Change-Id: I9067ff9b47085d7f08017ff70955227fdd3a5b41
This commit is contained in:
Simon Westphahl 2022-09-26 12:48:46 +02:00
parent 5ee975995e
commit 33edf53f36
No known key found for this signature in database

View File

@ -19,6 +19,7 @@ import logging
import threading
import git
from opentelemetry import trace
from zuul.driver.git.gitmodel import EMPTY_GIT_REF
from zuul.zk.event_queues import EventReceiverElection
@ -27,6 +28,7 @@ from zuul.zk.event_queues import EventReceiverElection
# This class may be used by any driver to implement git head polling.
class GitWatcher(threading.Thread):
log = logging.getLogger("zuul.connection.git.watcher")
tracer = trace.get_tracer("zuul")
def __init__(self, connection, baseurl, poll_delay, callback,
election_name="watcher"):
@ -134,8 +136,9 @@ class GitWatcher(threading.Thread):
self.projects_refs[project] = refs
# Send events to the scheduler
for event in events:
self.log.debug("Sending event: %s" % event)
self.callback(event)
with self.tracer.start_as_current_span("GitEvent"):
self.log.debug("Sending event: %s" % event)
self.callback(event)
self._event_count += 1
def _run(self):