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

fix(codecs): Ensure that batches using newline delimited framing end in a newline #21097

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jszwedko
Copy link
Member

Fixes: #21086

Signed-off-by: Jesse Szwedko [email protected]

@jszwedko jszwedko requested a review from a team as a code owner August 16, 2024 22:25
@github-actions github-actions bot added the domain: codecs Anything related to Vector's codecs (encoding/decoding) label Aug 16, 2024
@datadog-vectordotdev
Copy link

datadog-vectordotdev bot commented Aug 16, 2024

Datadog Report

Branch report: jszwedko/add-batch-trailing-newline
Commit report: aa6e9ef
Test service: vector

❌ 6 Failed (0 Known Flaky), 334 Passed, 0 Skipped, 4m 18.73s Total Time

❌ Failed Tests (6)

This report shows up to 5 failed tests.

  • sinks::nats::integration_tests::nats_tls_client_cert_valid - vector - Details

    Expand for error
     Test failed, but output was not captured
    
  • sinks::nats::integration_tests::nats_tls_jwt_auth_valid - vector - Details

    Expand for error
     Test failed, but output was not captured
    
  • sinks::nats::integration_tests::nats_tls_valid - vector - Details

    Expand for error
     Test failed, but output was not captured
    
  • sources::nats::integration_tests::nats_tls_client_cert_valid - vector - Details

    Expand for error
     Test failed, but output was not captured
    
  • sources::nats::integration_tests::nats_tls_jwt_auth_valid - vector - Details

    Expand for error
     Test failed, but output was not captured
    

Copy link
Contributor

@neuronull neuronull left a comment

Choose a reason for hiding this comment

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

It does feel a bit strange that this is only coming up now 🤔

src/codecs/encoding/encoder.rs Show resolved Hide resolved
@jszwedko
Copy link
Member Author

It does feel a bit strange that this is only coming up now 🤔

Agreed. I think most consumers would handle newline or EOF as the delimiter though so needing the trailing newline may not be a common need. I think it is more "correct" though and less likely to cause weird issues if EOFs aren't handled as delimiters.

@github-actions github-actions bot added the domain: sinks Anything related to the Vector's sinks label Aug 19, 2024
@jszwedko jszwedko requested a review from neuronull August 19, 2024 22:01
@@ -93,12 +93,14 @@ impl Encoder<Framer> {
}

/// Get the suffix that encloses a batch of events.
pub const fn batch_suffix(&self) -> &[u8] {
match (&self.framer, &self.serializer) {
pub const fn batch_suffix(&self, empty: bool) -> &[u8] {
Copy link
Member Author

@jszwedko jszwedko Aug 19, 2024

Choose a reason for hiding this comment

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

I think ideally the encoding, for newline delimited framing, would append the newline while encoding each element (including the last) rather than adding it when finalizing the batch, but that was a bit more refactoring than I was willing to take on at the moment.

Copy link
Contributor

@neuronull neuronull left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: codecs Anything related to Vector's codecs (encoding/decoding) domain: sinks Anything related to the Vector's sinks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Final newline character missing when using AWS S3 sink
2 participants