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

Don't panic on debug when packets aren't utf-8 #156

Merged
merged 2 commits into from
Dec 10, 2020
Merged

Conversation

markmandel
Copy link
Member

The current debug logging assumes a packet is utf-8, and if not, it panics, which is bad.

This provides a fallback output if the packet is not utf-8, and introduces a debug module to add tools to for debug builds and
debugging in general.

Closes #151

@markmandel markmandel added the kind/bug Something isn't working label Dec 6, 2020
@markmandel markmandel requested a review from iffyio December 6, 2020 17:45
@google-cla google-cla bot added the cla: yes label Dec 6, 2020
The current debug logging assumes a packet is utf-8, and if not, it
panics, which is bad.

This provides a fallback output if the packet is not utf-8, and
introduces a `debug` module to add tools to for debug builds and
debugging in general.

Closes #151
Copy link
Collaborator

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

I'm thinking we should log these messages at trace rather than debug since this is probably as low level a message as it gets? e.g if one enables debug temporarily these messages will be very chatty and can drown out other relevant ones

src/debug.rs Outdated
@@ -0,0 +1,22 @@
/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we nest the file under a directory e.g src/utils/debug.rs, src/helpers/debug.rs etc? If we have lots of these helper modules the src/ directory structure could get confusing e.g it'll be hard to tell looking at the folder structure what src/debug.rs is

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we nest the file under a directory e.g src/utils/debug.rs

I like it! I'll make this change 👍

I'm thinking we should log these messages at trace rather than debug since this is probably as low level a message as it gets?

I keep going back and forth on this - I really like having these at debug level, and I think the information is very useful for debugging low-traffic problems, and having it readily available is handy. But I also hear that in production systems, this can become more signal than noise (which can be fixed with tooling, but that's a whole other thing).

Sounds like we need a tie breaker 😄 @luna-duclos do you want to weigh in here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd say detailed packet dumping should be trace, its rarely needed and you'd usually want it on a node thats not receiving significant traffic.

Copy link
Member Author

Choose a reason for hiding this comment

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

From Discord:

Kebbe • Luna Duclos Today at 10:39 AM
imo, trace.

Well, it seems like the prevailing opinion is trace level - so I defer to the everyone else expert opinions! I'll make this change.

@markmandel
Copy link
Member Author

Updates made! PTAL!

Copy link
Collaborator

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

LGTM!

@markmandel markmandel merged commit 2266ff4 into master Dec 10, 2020
@markmandel markmandel deleted the bug/debug-utf8 branch December 10, 2020 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not parse packets as utf8
3 participants