mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
feat(connectors): add connector sync spans
This commit is contained in:
parent
4e3a6dff46
commit
7c07c220fc
1 changed files with 7 additions and 2 deletions
|
|
@ -8,7 +8,7 @@ from collections.abc import Awaitable, Callable
|
||||||
from celery import current_task
|
from celery import current_task
|
||||||
|
|
||||||
from app.celery_app import celery_app
|
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 (
|
from app.tasks.celery_tasks import (
|
||||||
get_celery_session_maker,
|
get_celery_session_maker,
|
||||||
run_async_celery_task as _run_async_celery_task,
|
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()
|
t0 = time.perf_counter()
|
||||||
status = "failed"
|
status = "failed"
|
||||||
try:
|
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"
|
status = "success"
|
||||||
return result
|
return result
|
||||||
|
except Exception:
|
||||||
|
status = "failed"
|
||||||
|
raise
|
||||||
finally:
|
finally:
|
||||||
elapsed_s = time.perf_counter() - t0
|
elapsed_s = time.perf_counter() - t0
|
||||||
ot_metrics.record_connector_sync_duration(
|
ot_metrics.record_connector_sync_duration(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue