Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
LostVector committed Jan 6, 2025
1 parent d26f8ce commit ca54bd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/onyx/background/celery/apps/primary.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ def on_worker_init(sender: Any, **kwargs: Any) -> None:
app_base.wait_for_db(sender, **kwargs)
app_base.wait_for_vespa(sender, **kwargs)

logger.info("Running as the primary celery worker.")

# Less startup checks in multi-tenant case
if MULTI_TENANT:
return

logger.info("Running as the primary celery worker.")

# This is singleton work that should be done on startup exactly once
# by the primary worker. This is unnecessary in the multi tenant scenario
r = get_redis_client(tenant_id=None)
Expand Down
5 changes: 4 additions & 1 deletion backend/onyx/background/celery/tasks/vespa/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,8 @@ def monitor_vespa_sync(self: Task, tenant_id: str | None) -> bool:
Returns True if the task actually did work, False if it exited early to prevent overlap
"""
task_logger.info(f"monitor_vespa_sync starting: tenant={tenant_id}")

time_start = time.monotonic()

timings: dict[str, float] = {}
Expand All @@ -775,6 +777,7 @@ def monitor_vespa_sync(self: Task, tenant_id: str | None) -> bool:
try:
# prevent overlapping tasks
if not lock_beat.acquire(blocking=False):
task_logger.info("monitor_vespa_sync exiting due to overlap")
return False

# print current queue lengths
Expand Down Expand Up @@ -894,7 +897,7 @@ def monitor_vespa_sync(self: Task, tenant_id: str | None) -> bool:
redis_lock_dump(lock_beat, r)

time_elapsed = time.monotonic() - time_start
task_logger.debug(f"monitor_vespa_sync finished: elapsed={time_elapsed:.2f}")
task_logger.info(f"monitor_vespa_sync finished: elapsed={time_elapsed:.2f}")
return True


Expand Down

0 comments on commit ca54bd0

Please sign in to comment.