mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-03 02:20:04 +00:00
- Go module: github.com/SigNoz/signoz-otel-collector → github.com/hanzoai/otel-collector - All signoz-prefixed packages → o11y-prefixed - Docker: signoz/* → ghcr.io/hanzoai/otel-collector - ClickHouse exporter → Hanzo Datastore - Env vars: SIGNOZ_* → HANZO_* - Directory renames for all processor/receiver/exporter packages
49 lines
944 B
Go
49 lines
944 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package compression // import "github.com/hanzoai/otel-collector/receiver/o11yawsfirehosereceiver/internal/unmarshaler/cwlog/compression"
|
|
|
|
import (
|
|
"bytes"
|
|
"compress/gzip"
|
|
)
|
|
|
|
// Zip returns a gzip-compressed representation of the input bytes.
|
|
func Zip(data []byte) ([]byte, error) {
|
|
var b bytes.Buffer
|
|
w := gzip.NewWriter(&b)
|
|
|
|
_, err := w.Write(data)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err = w.Flush(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err = w.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return b.Bytes(), nil
|
|
}
|
|
|
|
// Unzip expects gzip-compressed input bytes and returns their uncompressed form.
|
|
func Unzip(data []byte) ([]byte, error) {
|
|
b := bytes.NewBuffer(data)
|
|
|
|
r, err := gzip.NewReader(b)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var rv bytes.Buffer
|
|
_, err = rv.ReadFrom(r)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return rv.Bytes(), nil
|
|
}
|