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

Refactor session metrics and errors #613

Merged
merged 1 commit into from
Sep 30, 2022
Merged

Refactor session metrics and errors #613

merged 1 commit into from
Sep 30, 2022

Conversation

XAMPPRocky
Copy link
Collaborator

Refactors session metrics to use static variables, this saves us 80 bytes per session (plus some more from being cloned down from proxy). The one downside is that I had to remove one test, because using static variables for metrics doesn't work well the with multithreaded tests. But the test was simple enough that I think it's worth losing that small bit of coverage.

It also refactors session's errors to be more helpful, and include more information when logged. I did this through a through a trait so that later we can make it easier to log other errors and types without duplication. I also refactored the branches in the packet send code to ensure that PACKETS_DROPPED is always being incremented when we don't send packets.

@@ -70,5 +70,5 @@ async fn metrics_server() {

let response = String::from_utf8(resp.to_vec()).unwrap();
dbg!(&response);
assert!(response.contains("quilkin_session_tx_packets_total 1"));
assert!(response.contains(r#"quilkin_packets_total{event="read"} 2"#));
Copy link
Collaborator Author

@XAMPPRocky XAMPPRocky Sep 30, 2022

Choose a reason for hiding this comment

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

This is now 2 because this test uses two Quilkin proxies.

Refactors session metrics to use static variables, this saves us 80
bytes per session (plus some more from being cloned down from proxy).
The one downside is that I had to remove one test, because using static
variables for metrics doesn't work well the with multithreaded tests.
But the test was simple enough that I think it's worth losing that small
bit of coverage.

It also refactors session's errors to be more helpful, and include more
information when logged. I did this through a through a trait so that
later we can make it easier to log other errors and types without
duplication. I also refactored the branches in the packet send code to
ensure that `PACKETS_DROPPED` is always being incremented when we don't
send packets.
@quilkin-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 22f66bd6-203d-43f1-868f-9fcef11f3ac4

The following development images have been built, and will exist for the next 30 days:

To build this version:

git fetch git@github.com:googleforgames/quilkin.git pull/613/head:pr_613 && git checkout pr_613
cargo build

Copy link
Contributor

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

LGTM. Agreed it's a shame that we lose the coverage, but it's much cleaner, and will save us on passing through the date each time.

Not from this PR, but just making a note for later: packets_dropped should probably be packets_dropped_total, same with packets_size - just to have consistent naming (and I'm fairly sure that's the nomenclature for metrics).

@markmandel markmandel merged commit 8c41cdd into main Sep 30, 2022
@markmandel markmandel deleted the ep/refactor-session branch September 30, 2022 20:39
XAMPPRocky added a commit that referenced this pull request Oct 10, 2022
Refactors session metrics to use static variables, this saves us 80
bytes per session (plus some more from being cloned down from proxy).
The one downside is that I had to remove one test, because using static
variables for metrics doesn't work well the with multithreaded tests.
But the test was simple enough that I think it's worth losing that small
bit of coverage.

It also refactors session's errors to be more helpful, and include more
information when logged. I did this through a through a trait so that
later we can make it easier to log other errors and types without
duplication. I also refactored the branches in the packet send code to
ensure that `PACKETS_DROPPED` is always being incremented when we don't
send packets.
XAMPPRocky added a commit that referenced this pull request Oct 10, 2022
Refactors session metrics to use static variables, this saves us 80
bytes per session (plus some more from being cloned down from proxy).
The one downside is that I had to remove one test, because using static
variables for metrics doesn't work well the with multithreaded tests.
But the test was simple enough that I think it's worth losing that small
bit of coverage.

It also refactors session's errors to be more helpful, and include more
information when logged. I did this through a through a trait so that
later we can make it easier to log other errors and types without
duplication. I also refactored the branches in the packet send code to
ensure that `PACKETS_DROPPED` is always being incremented when we don't
send packets.
@markmandel markmandel added the kind/cleanup Refactoring code, fixing up documentation, etc label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Refactoring code, fixing up documentation, etc size/l
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants