This patch adds support for Opentelemetry. If OTEL_EXPORTER_OTLP_ENDPOINT env variable is defined, it will send traces there. Otherwise there is no change. The whole compose is wrapped in a single span. Nested under that are spans for operations that involve a remote server. * Talking to CTS * Sending API requests to Koji * Any git repo clone Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com> (cherry picked from commit c15ddbc946cc6a820dfb2f0bbacb72ca118100ba)
22 lines
719 B
Python
22 lines
719 B
Python
from kobo.threads import WorkerThread
|
|
|
|
from .otel import tracing
|
|
|
|
|
|
class TelemetryWorkerThread(WorkerThread):
|
|
"""
|
|
Subclass of WorkerThread that captures current context when the thread is
|
|
created, and restores the context in the new thread.
|
|
|
|
A regular WorkerThread would start from an empty context, leading to any
|
|
spans created in the thread disconnected from the overall trace.
|
|
"""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
self.traceparent = tracing.get_traceparent()
|
|
super(TelemetryWorkerThread, self).__init__(*args, **kwargs)
|
|
|
|
def run(self, *args, **kwargs):
|
|
tracing.set_context(self.traceparent)
|
|
super(TelemetryWorkerThread, self).run(*args, **kwargs)
|