diff --git a/app/vmalert/remotewrite/remotewrite.go b/app/vmalert/remotewrite/remotewrite.go index caff50a5c..c51be5168 100644 --- a/app/vmalert/remotewrite/remotewrite.go +++ b/app/vmalert/remotewrite/remotewrite.go @@ -226,14 +226,14 @@ func (c *Client) send(ctx context.Context, data []byte) error { r := bytes.NewReader(data) req, err := http.NewRequest("POST", c.addr, r) if err != nil { - return fmt.Errorf("failed to create new HTTP request: %s", err) + return fmt.Errorf("failed to create new HTTP request: %w", err) } if c.baPass != "" { req.SetBasicAuth(c.baUser, c.baPass) } resp, err := c.c.Do(req.WithContext(ctx)) if err != nil { - return fmt.Errorf("error while sending request to %s: %s; Data len %d(%d)", + return fmt.Errorf("error while sending request to %s: %w; Data len %d(%d)", req.URL, err, len(data), r.Size()) } defer func() { _ = resp.Body.Close() }() diff --git a/app/vmalert/remotewrite/remotewrite_test.go b/app/vmalert/remotewrite/remotewrite_test.go index 7dab24712..18a9cfff6 100644 --- a/app/vmalert/remotewrite/remotewrite_test.go +++ b/app/vmalert/remotewrite/remotewrite_test.go @@ -82,19 +82,19 @@ func (rw *rwServer) handler(w http.ResponseWriter, r *http.Request) { } data, err := ioutil.ReadAll(r.Body) if err != nil { - rw.err(w, fmt.Errorf("body read err: %s", err)) + rw.err(w, fmt.Errorf("body read err: %w", err)) return } defer func() { _ = r.Body.Close() }() b, err := snappy.Decode(nil, data) if err != nil { - rw.err(w, fmt.Errorf("decode err: %s", err)) + rw.err(w, fmt.Errorf("decode err: %w", err)) return } wr := &prompb.WriteRequest{} if err := wr.Unmarshal(b); err != nil { - rw.err(w, fmt.Errorf("unmarhsal err: %s", err)) + rw.err(w, fmt.Errorf("unmarhsal err: %w", err)) return } atomic.AddUint64(&rw.acceptedRows, uint64(len(wr.Timeseries)))