Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Jan 22, 2025
1 parent 0fec9ef commit 691cfc5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions backend/onyx/background/celery/tasks/monitoring/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,9 @@ def _collect_connector_metrics(db_session: Session, redis_std: Redis) -> list[Me
# Get all attempts in the last hour
recent_attempts = (
db_session.query(IndexAttempt)
.filter(
IndexAttempt.connector_credential_pair_id == cc_pair.id,
IndexAttempt.time_created >= one_hour_ago,
)
.filter(IndexAttempt.connector_credential_pair_id == cc_pair.id)
.order_by(IndexAttempt.time_created.desc())
.limit(2)
.all()
)
most_recent_attempt = recent_attempts[0] if recent_attempts else None
Expand All @@ -265,7 +263,10 @@ def _collect_connector_metrics(db_session: Session, redis_std: Redis) -> list[Me
)

# if no metric to emit, skip
if most_recent_attempt is None:
if (
most_recent_attempt is None
or one_hour_ago > most_recent_attempt.time_created
):
continue

# Connector start latency
Expand Down

0 comments on commit 691cfc5

Please sign in to comment.