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

Add GZIP compression to collector endpoint #95

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

Ivaka
Copy link
Contributor

@Ivaka Ivaka commented Jan 25, 2024

No description provided.

@Ivaka Ivaka self-assigned this Jan 25, 2024
@Ivaka Ivaka force-pushed the REP-597/add-compression-to-collector branch from 0ed08ca to a8db5e4 Compare January 25, 2024 08:59
@Ivaka Ivaka force-pushed the REP-597/add-compression-to-collector branch from a8db5e4 to 6a9320c Compare January 25, 2024 09:08
collector/collector.go Outdated Show resolved Hide resolved
@Ivaka Ivaka force-pushed the REP-597/add-compression-to-collector branch from ef49d1b to d260baf Compare January 26, 2024 10:49
@@ -154,6 +170,32 @@ func (c *Collector) GetRawNetworkMetricsHandler(w http.ResponseWriter, req *http
}
}

func (c *Collector) writeGzipBody(w http.ResponseWriter, body []byte) error {
writer, err := gzip.NewWriterLevel(w, gzip.BestCompression)
if err != nil {
Copy link

Choose a reason for hiding this comment

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

NIT: It's probably not worth checking the error in this case.

The error returned will be nil if the level is valid.

https://pkg.go.dev/compress/gzip#NewWriterLevel

@Ivaka Ivaka force-pushed the REP-597/add-compression-to-collector branch from d260baf to dd964e1 Compare January 26, 2024 11:50
@Ivaka Ivaka merged commit 71a3541 into main Jan 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants