Skip to content

Adds snappy support for http_listener_v2#8966

Merged
helenosheaa merged 10 commits intomasterfrom
snappy-http-support
Mar 18, 2021
Merged

Adds snappy support for http_listener_v2#8966
helenosheaa merged 10 commits intomasterfrom
snappy-http-support

Conversation

@helenosheaa
Copy link
Copy Markdown
Member

@helenosheaa helenosheaa commented Mar 10, 2021

Adds snappy support plus test

Relates to #8682, #8967 - one use is for with prometheus remote write parsing

Copy link
Copy Markdown
Contributor

@telegraf-tiger telegraf-tiger bot left a comment

Choose a reason for hiding this comment

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

🤝 ✅ CLA has been signed. Thank you!

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Mar 10, 2021
Copy link
Copy Markdown
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

I would prefer to match the pattern of gzip and construct a reader. Is there any reason to not do it this way?

@helenosheaa
Copy link
Copy Markdown
Member Author

Thanks for the review, I'll take a look at matching the gzip pattern

@helenosheaa
Copy link
Copy Markdown
Member Author

helenosheaa commented Mar 11, 2021

So after just having another look at the docs, we want to use Decode rather than a NewReader as we need the block format rather than streaming format (specifically for the prometheus remote write use case). Bit more context here

Copy link
Copy Markdown
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@srebhan srebhan self-assigned this Mar 12, 2021
@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Mar 12, 2021
}

// Handle snappy request bodies
if req.Header.Get("Content-Encoding") == "snappy" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

About 20 lines above there's a similar block for gzip. It looks like we should change the "if content-encoding == gzip" to a switch statement that also handles snappy, then move this new block into the switch statement. The snappy decoding needs to happen at the same place gzip does, namely before the MaxBytesReader.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The NewReader function of snappy would return a reader such as the gzip implementation so the switch would work but the block implementation of snappy that we need (for prometheus remote write) is a Decode which takes in bytes and returns bytes. So I think it needs to be after the reader on 266 unless I'm missing something.

@helenosheaa helenosheaa merged commit cc6c51c into master Mar 18, 2021
@helenosheaa helenosheaa deleted the snappy-http-support branch March 18, 2021 15:33
jblesener pushed a commit to jblesener/telegraf that referenced this pull request Apr 18, 2021
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants