diff options
Diffstat (limited to 'zuul/driver/pagure/pagureconnection.py')
-rw-r--r-- | zuul/driver/pagure/pagureconnection.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/zuul/driver/pagure/pagureconnection.py b/zuul/driver/pagure/pagureconnection.py index 4fba2a27e..e22134015 100644 --- a/zuul/driver/pagure/pagureconnection.py +++ b/zuul/driver/pagure/pagureconnection.py @@ -23,12 +23,15 @@ import requests import cherrypy import voluptuous as v +from opentelemetry import trace + from zuul.connection import ( BaseConnection, ZKChangeCacheMixin, ZKBranchCacheMixin ) from zuul.lib.logutil import get_annotated_logger from zuul.web.handler import BaseWebController from zuul.model import Ref, Branch, Tag +from zuul.lib import tracing from zuul.lib import dependson from zuul.zk.branch_cache import BranchCache from zuul.zk.change_cache import ( @@ -118,6 +121,7 @@ class PagureEventConnector(threading.Thread): """Move events from Pagure into the scheduler""" log = logging.getLogger("zuul.PagureEventConnector") + tracer = trace.get_tracer("zuul") def __init__(self, connection): super(PagureEventConnector, self).__init__() @@ -170,10 +174,17 @@ class PagureEventConnector(threading.Thread): def _run(self): while not self._stopped: for event in self.event_queue: - try: - self._handleEvent(event) - finally: - self.event_queue.ack(event) + event_span = tracing.restoreSpanContext( + event.get("span_context")) + attributes = {"rel": "PagureEvent"} + link = trace.Link(event_span.get_span_context(), + attributes=attributes) + with self.tracer.start_as_current_span( + "PagureEventProcessing", links=[link]): + try: + self._handleEvent(event) + finally: + self.event_queue.ack(event) if self._stopped: return self._process_event.wait(10) @@ -826,6 +837,7 @@ class PagureConnection(ZKChangeCacheMixin, ZKBranchCacheMixin, BaseConnection): class PagureWebController(BaseWebController): log = logging.getLogger("zuul.PagureWebController") + tracer = trace.get_tracer("zuul") def __init__(self, zuul_web, connection): self.connection = connection @@ -874,6 +886,7 @@ class PagureWebController(BaseWebController): @cherrypy.expose @cherrypy.tools.json_out(content_type='application/json; charset=utf-8') + @tracer.start_as_current_span("PagureEvent") def payload(self): # https://docs.pagure.org/pagure/usage/using_webhooks.html headers = dict() @@ -889,7 +902,10 @@ class PagureWebController(BaseWebController): "Payload origin IP address whitelisted. Skip verify") json_payload = json.loads(body.decode('utf-8')) - data = {'payload': json_payload} + data = { + 'payload': json_payload, + 'span_context': tracing.getSpanContext(trace.get_current_span()), + } self.event_queue.put(data) return data |