Skip to content

Conversation

@filiptronicek
Copy link
Member

@filiptronicek filiptronicek commented Sep 24, 2024

Description

Makes log streaming not utilize any fixed-size buffers, and instead accepts not just \n, but also \r as a newline character.

Related Issue(s)

Fixes ENT-629

How to test

You can test logging by cloning a repo under /workspace and executing something along the lines of the following (from components/gitpod-cli):

go run . validate --workspace-folder /workspace/spring-petclinic/ --headless --prebuild

A test of some common scenarios (such as long line entries, multibyte Unicode characters and same-line updates) can be tested by running this on https://github.com/filiptronicek/test-foofies/tree/ft/log.


char := buffer.Next(size)

if r == '\n' || r == '\r' {
Copy link
Member

Choose a reason for hiding this comment

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

What other (line-)control characters would we need to support as well? (wikipedia). And: Do we need to handle the windows line ending (/r/n) as well? 🤔

Otherwise, I think this is a nice approach navigating the difficulties we discussed yesterday, especially in the face of "merging multiple streams". 💪

Copy link
Member

Choose a reason for hiding this comment

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

Also, would it make sense to add (minimal) tests for this decoding/forwarding logic? I imagine extracting a the core function would help a lot.

Also2, 1-2 lines of comments on "why this approach", especially vs. "just forward byte stream", would be 🥇 .

Copy link
Member Author

Choose a reason for hiding this comment

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

Totally agree about the tests and comment-adding. Took a look at the Wikipedia page you linked, and it looks like only \b could be interesting for us (in addition to \r and \t?

Added changes in f87e49e (#20238)

@roboquat roboquat added size/L and removed size/M labels Sep 24, 2024
return
}
flushLine := func() {
if line.Len() > 0 {
Copy link
Member Author

Choose a reason for hiding this comment

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

this has a catch.

Pros:

  • When we read Windows-like line endings (\r\n), we treat it as a single line-break

Cons:

  • A hundred line breaks will be treated as 0 if the line has no other content

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

Code and tests LGTM! Nice works 💪 ✔️

@filiptronicek
Copy link
Member Author

@roboquat roboquat merged commit 1accbd9 into main Sep 24, 2024
17 checks passed
@roboquat roboquat deleted the ft/gp-validate-better-log-streaming branch September 24, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants