From 7c07c220fc3dc7b0935cf080b5dbd9a2310a561f Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Fri, 22 May 2026 13:49:59 +0530 Subject: [PATCH] feat(connectors): add connector sync spans --- .../app/tasks/celery_tasks/connector_tasks.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/surfsense_backend/app/tasks/celery_tasks/connector_tasks.py b/surfsense_backend/app/tasks/celery_tasks/connector_tasks.py index 86296c3d9..e0f0f09c9 100644 --- a/surfsense_backend/app/tasks/celery_tasks/connector_tasks.py +++ b/surfsense_backend/app/tasks/celery_tasks/connector_tasks.py @@ -8,7 +8,7 @@ from collections.abc import Awaitable, Callable from celery import current_task from app.celery_app import celery_app -from app.observability import metrics as ot_metrics +from app.observability import metrics as ot_metrics, otel as ot from app.tasks.celery_tasks import ( get_celery_session_maker, run_async_celery_task as _run_async_celery_task, @@ -23,9 +23,14 @@ def run_async_celery_task[T](coro_factory: Callable[[], Awaitable[T]]) -> T: t0 = time.perf_counter() status = "failed" try: - result = _run_async_celery_task(coro_factory) + with ot.connector_sync_span(connector_type=task_name) as sp: + result = _run_async_celery_task(coro_factory) + sp.set_attribute("connector.status", "success") status = "success" return result + except Exception: + status = "failed" + raise finally: elapsed_s = time.perf_counter() - t0 ot_metrics.record_connector_sync_duration(