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

Adds new statistics attributes for tracking connections closed #205

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

pfreixes
Copy link
Contributor

@pfreixes pfreixes commented Jun 12, 2024

The two new attributes connections_closed_broken and connections_closed_invalid can be used for respectively understand how many connections were closed due to be considered broken or invalid.

The StatsKind internal enum was also renamed to StatsGetKind for better clarity.

Note: A new PR for tracking the reaped connections will be created on top of these changes.

Copy link
Owner

@djc djc left a comment

Choose a reason for hiding this comment

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

Please squash the suggested changes into your second commit.

@@ -290,3 +305,8 @@ pub(crate) enum StatsGetKind {
Waited,
TimedOut,
}

pub(crate) enum StatsConnectionClosedKind {
Copy link
Owner

Choose a reason for hiding this comment

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

Since there's nothing "special" about these values, let's just call this StatsKind again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH i would prefer to keep the ConnectionClosed since this is used for recording closed connections, but Ill make the change

Copy link
Owner

@djc djc Jun 13, 2024

Choose a reason for hiding this comment

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

It can be used for any kind of simple increment of AtomicU64. There's nothing in the record() logic that is specific to ConnectionClosed events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its ok, lets see how record evolves .... BTW added the changes that you asked

Copy link
Owner

Choose a reason for hiding this comment

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

If we rename the enum might also rename the variants to be like ClosedBroken, ClosedInvalid.


pub(crate) fn record(&self, kind: StatsConnectionClosedKind) {
match kind {
StatsConnectionClosedKind::Broken => self
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe yield &self.connections_closed_broken from the match arm and then move the .fetch_add(1, Ordering::SeqCst) call out of the `match?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try it, but to me seems to overcomplicate things for just trying to make the code less verbose but making it less readable.

Copy link
Owner

Choose a reason for hiding this comment

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

I prefer the conciseness and reduced duplication.

@pfreixes pfreixes force-pushed the record_connections_closed_2 branch from 2b787ac to 5f8886b Compare June 13, 2024 10:37
@pfreixes
Copy link
Contributor Author

@djc squashed requested changes into my latest commit PTAL one you have a moment

@djc
Copy link
Owner

djc commented Jun 13, 2024

I'm not seeing the changes I suggested appear in your commit, I think? Are you sure your squashing worked as expected?

@pfreixes pfreixes force-pushed the record_connections_closed_2 branch from 5f8886b to c22505a Compare June 13, 2024 16:09
@pfreixes
Copy link
Contributor Author

@djc, forgot to add the files changed 🤦

StatsKind::ClosedBroken => &self.connections_closed_broken,
StatsKind::ClosedInvalid => &self.connections_closed_invalid,
};
stats.fetch_add(1, Ordering::SeqCst);
Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, I meant you can chain the fetch_add() directly onto the match { .. } without binding it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problemo, I guess that behind the scenes the compiler will do the same right? In any case less code is better, feedback applied with squashing.

Copy link
Owner

@djc djc left a comment

Choose a reason for hiding this comment

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

One minor nit!

The two new attributes `connections_closed_broken` and
`connections_closed_invalid` can be used for respectively understand how
many conections were closed due to be considered broken or invalid.
@pfreixes pfreixes force-pushed the record_connections_closed_2 branch from c22505a to 3e35964 Compare June 13, 2024 16:19
@djc djc merged commit fc9a823 into djc:main Jun 13, 2024
7 of 8 checks passed
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