mirror of
https://github.com/hanzoai/metrics.git
synced 2026-10-30 20:03:39 +00:00
Improve remote write handling in vmagent by setting the `Content-Encoding` header based on the actual request body, rather than relying on configuration. - Detects Zstd compression via the Zstd magic number. - Falls back to Snappy if Zstd is not detected. - Persistent queue may now contain mixed-encoding content. - Add basic vmagent integration tests Follow up on https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5344 and https://github.com/VictoriaMetrics/VictoriaMetrics/commit/12cd32fd75706969f972a328e8583ca1da9e68c3. Extracted from https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8462 Related issue: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5301
13 lines
443 B
Go
13 lines
443 B
Go
package encoding
|
|
|
|
import "encoding/binary"
|
|
|
|
// IsZstd checks if the given data is compressed using the zstd format.
|
|
// It does this by verifying the presence of the zstd magic number (0xFD2FB528)
|
|
// at the beginning of the byte slice.
|
|
//
|
|
// See: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#zstandard-frames
|
|
func IsZstd(data []byte) bool {
|
|
return len(data) >= 4 && binary.LittleEndian.Uint32(data) == 0xFD2FB528
|
|
}
|