Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new statistics for knowing when and why connections were closed #204

Closed
wants to merge 1 commit into from

Conversation

pfreixes
Copy link
Contributor

We add 4 new statistics which will be used by the users for knowing when the connections were closed and what was the reason, the new four statistics are:

  • connections_closed_broken: Total connections that were closed due to be in broken state.
  • connections_closed_invalid: Total connections that were closed due to be considered invalid.
  • connections_closed_max_lifetime: Total connections that were closed because they reached the max lifetime.
  • connections_closed_idle_timeout: Total connections that were closed because they reached the idle timeout.

We add 4 new statistics which will be used by the users for knowing when
the connections were closed and what was the reason, the new four
statistics are:

- `connections_closed_broken`: Total connections that were closed due to be in broken state.
- `connections_closed_invalid`: Total connections that were closed due to be considered invalid.
- `connections_closed_max_lifetime`: Total connections that were closed
  because they reached the max lifetime.
- `connections_closed_idle_timeout`: Total connections that were closed
  because they reached the idle timeout.
@@ -85,7 +87,7 @@ where
}

pub(crate) async fn get(&self) -> Result<PooledConnection<'_, M>, RunError<M::Error>> {
let mut kind = StatsKind::Direct;
let mut kind = StatsGetKind::Direct;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this change in a separate commit or PR.

@@ -139,22 +143,34 @@ where
ApprovalIter { num: num as usize }
}

pub(crate) fn reap(&mut self, config: &Builder<M>) -> ApprovalIter {
pub(crate) fn reap(&mut self, config: &Builder<M>) -> (ApprovalIter, u64, u64) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's split the reap() changes out in a separate PR.

@@ -272,6 +292,28 @@ impl AtomicStatistics {
.fetch_add(wait_time.as_micros() as u64, Ordering::SeqCst);
}
}

pub(crate) fn record_connection_closed(&self, kind: StatsConnectionClosedKind) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be named record().

@pfreixes
Copy link
Contributor Author

Closing this one in favour of #205

@pfreixes pfreixes closed this Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants