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): Use '\0' delimiter as default stream decode framer #20778

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

Conversation

jorgehermo9
Copy link

@jorgehermo9 jorgehermo9 commented Jul 2, 2024

Closes #20768.

I think that in my local environment some test fail but has nothing to do with the changes I did. Could you trigger them here and if its fails too in the CI I review what could happen?

Thanks

@bits-bot
Copy link

bits-bot commented Jul 2, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the domain: codecs Anything related to Vector's codecs (encoding/decoding) label Jul 2, 2024
@@ -53,7 +59,7 @@ pub struct CharacterDelimitedDecoderOptions {

impl CharacterDelimitedDecoderOptions {
/// Create a `CharacterDelimitedDecoderOptions` with a delimiter and optional max_length.
pub fn new(delimiter: u8, max_length: Option<usize>) -> Self {
pub const fn new(delimiter: u8, max_length: Option<usize>) -> Self {
Copy link
Author

Choose a reason for hiding this comment

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

Noticed this and didn't hurt

| SerializerConfig::Json(_)
| SerializerConfig::Logfmt
| SerializerConfig::NativeJson
| SerializerConfig::RawMessage
| SerializerConfig::Text(_) => FramingConfig::NewlineDelimited,
SerializerConfig::Gelf => {
Copy link
Author

Choose a reason for hiding this comment

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

In order to be consistent with the default_stream_framing of the DeserializerConfig. Noticed that this change was missing in #18008. Changed it here, but tell me if you want this PR to not do anything out of scope from #20768.

Copy link
Member

Choose a reason for hiding this comment

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

Huh, yeah, this does seem like an oversight. I'm trying to understand the impact of it though since the original PR did seem to resolve the issue for people 🤔

@@ -138,4 +138,33 @@ mod tests {
let event = next.unwrap().0.pop().unwrap().into_log();
assert_eq!(event.get("bar").unwrap(), &Value::from(2));
}

#[tokio::test]
async fn gelf_streaming_decoding() {
Copy link
Author

@jorgehermo9 jorgehermo9 Jul 2, 2024

Choose a reason for hiding this comment

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

Added this test, I don't know if its correct to place it here. Didn't find anywhere else to place it.

I'm new in this project and can't find some modules easily.
Maybe this test is more of an integration test/e2e test, but couldn't find any related in the root /tests directory. I'm missing something?

It would be nice to have something like a TCP socket integration test where we test this same behavior...As the default_stream_framing is also called in

.unwrap_or_else(|| decoding.default_stream_framing()),
.

I thought of adding a similar test like this in

//////// TCP TESTS ////////
, what do you think?
In that case, I would create a TCP config setting only decoding = DeserializerConfig::from(GelfDeserializerConfig)(and leaving the framing as None in that config) and see how the TCP initialization takes the default framer.

What are your thoughts of all of this?

@jorgehermo9 jorgehermo9 marked this pull request as draft July 2, 2024 21:32
@jorgehermo9
Copy link
Author

Please, note that this is a breaking change as we are changing the default framing.

Maybe someone configured a source to send '\n' delimited gelf messages and left the vector config as the default, asumming that it would be correct.

In my opinion, we should adhere to the stardard and go ahead with this "breaking change"

@jorgehermo9 jorgehermo9 marked this pull request as ready for review July 2, 2024 21:39
@jorgehermo9 jorgehermo9 changed the title fix(gelf): Use '\0' delimiter as default streaming framer fix!(gelf): Use '\0' delimiter as default streaming framer Jul 3, 2024
@jorgehermo9 jorgehermo9 changed the title fix!(gelf): Use '\0' delimiter as default streaming framer fix!(gelf): Use '\0' delimiter as default stream decode framer Jul 3, 2024
@jszwedko jszwedko changed the title fix!(gelf): Use '\0' delimiter as default stream decode framer fix(codecs)!: Use '\0' delimiter as default stream decode framer Jul 3, 2024
Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

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

Thanks for this fix @jorgehermo9!

Do you mind adding a changelog fragment? See https://github.com/vectordotdev/vector/blob/master/changelog.d/README.md

I think the test you added is ok. I'd actually be content with just testing the the default is set correctly without testing that it actually decode with the default config and \0 delimited input since the character delimited codec is tested separately. If anything, you could add a test to lib/codecs/src/decoding/framing/character_delimited.rs that tests \0 works as a delimiter, but I don't think it is strictly necessary.

| SerializerConfig::Json(_)
| SerializerConfig::Logfmt
| SerializerConfig::NativeJson
| SerializerConfig::RawMessage
| SerializerConfig::Text(_) => FramingConfig::NewlineDelimited,
SerializerConfig::Gelf => {
Copy link
Member

Choose a reason for hiding this comment

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

Huh, yeah, this does seem like an oversight. I'm trying to understand the impact of it though since the original PR did seem to resolve the issue for people 🤔

@jorgehermo9
Copy link
Author

Thanks for the review! I'll submit the changes asap.

I'd actually be content with just testing the the default is set correctly without testing that it actually decode with the default config and \0 delimited input since the character delimited codec is tested separately

Right, I will narrow the scope of that test, no problem. It seemed too simple for me to just test that, but it doesn't have sense to test the \0 framing there...

@jorgehermo9 jorgehermo9 changed the title fix(codecs)!: Use '\0' delimiter as default stream decode framer fix!(codecs): Use '\0' delimiter as default stream decode framer Jul 5, 2024
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GELF decoder's default framer with TCP input does not match the encoder's default
3 participants