Skip to content

Commit

Permalink
reporter: compress uploaded profiles with zstd
Browse files Browse the repository at this point in the history
  • Loading branch information
Gandem committed Aug 30, 2024
1 parent 8940338 commit 8d0a5c4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions reporter/datadog_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"strings"
"time"

"github.com/DataDog/zstd"
lru "github.com/elastic/go-freelru"
pprofile "github.com/google/pprof/profile"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -304,10 +305,14 @@ func (r *DatadogReporter) reportProfile(ctx context.Context) error {
}

// serialize the profile to a buffer and send it out
var b bytes.Buffer
if err := profile.Write(&b); err != nil {
b := new(bytes.Buffer)
compressed := zstd.NewWriter(b)
if err := profile.WriteUncompressed(compressed); err != nil {
return err
}
if err := compressed.Close(); err != nil {
return fmt.Errorf("failed to compress profile: %w", err)
}

if r.saveCPUProfile {
// write profile to cpu.pprof
Expand Down

0 comments on commit 8d0a5c4

Please sign in to comment.