Skip to content

Commit

Permalink
fix: max_in_use_session metric time
Browse files Browse the repository at this point in the history
  • Loading branch information
surbhigarg92 committed Dec 26, 2024
1 parent ac1ddbc commit d61b4f3
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,15 @@ void maintainPool() {
}
this.prevNumSessionsAcquired = SessionPool.this.numSessionsAcquired;
}

// Reset the start time for recording the maximum number of sessions
// in the pool.
Instant currTime = clock.instant();
if (currTime.isAfter(SessionPool.this.lastResetTime.plus(Duration.ofMinutes(10)))) {
SessionPool.this.maxSessionsInUse = SessionPool.this.numSessionsInUse;
SessionPool.this.lastResetTime = currTime;
}

removeIdleSessions(currTime);
// Now go over all the remaining sessions and see if they need to be kept alive explicitly.
keepAliveSessions(currTime);
Expand Down Expand Up @@ -2309,6 +2317,9 @@ enum Position {
@GuardedBy("lock")
private int maxSessionsInUse = 0;

@GuardedBy("lock")
private Instant lastResetTime = Clock.INSTANCE.instant();

@GuardedBy("lock")
private long numSessionsAcquired = 0;

Expand Down

0 comments on commit d61b4f3

Please sign in to comment.