push.go: properly flush compressed metrics to pushURL

This commit is contained in:
Aliaksandr Valialkin 2022-07-25 10:37:04 +03:00
parent b305bc011e
commit fe970f4df0
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1

View File

@ -133,6 +133,9 @@ func InitPushExt(pushURL string, interval time.Duration, extraLabels string, wri
if _, err := zw.Write(tmpBuf); err != nil { if _, err := zw.Write(tmpBuf); err != nil {
panic(fmt.Errorf("BUG: cannot write %d bytes to gzip writer: %s", len(tmpBuf), err)) panic(fmt.Errorf("BUG: cannot write %d bytes to gzip writer: %s", len(tmpBuf), err))
} }
if err := zw.Close(); err != nil {
panic(fmt.Errorf("BUG: cannot flush metrics to gzip writer: %s", err))
}
req, err := http.NewRequest("GET", pushURL, &bb) req, err := http.NewRequest("GET", pushURL, &bb)
if err != nil { if err != nil {
log.Printf("ERROR: metrics.push: cannot initialize request for metrics push to %q: %s", pushURLRedacted, err) log.Printf("ERROR: metrics.push: cannot initialize request for metrics push to %q: %s", pushURLRedacted, err)