Add cause for all context timeouts (#2862)

This commit is contained in:
Sanket Sudake
2023-10-29 13:19:06 +05:30
committed by GitHub
parent 2223081c80
commit 267f7faf18
6 changed files with 17 additions and 14 deletions
+2 -1
View File
@@ -19,6 +19,7 @@ package publisher
import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"strings"
@@ -121,7 +122,7 @@ func (p *WebhookPublisher) makeHTTPRequest(r *publishRequest) {
req.Header.Set(k, v)
}
// Make the request
ctx, cancel := context.WithTimeout(r.ctx, p.timeout)
ctx, cancel := context.WithTimeoutCause(r.ctx, p.timeout, fmt.Errorf("webhook request timed out (%f)s exceeded ", p.timeout.Seconds()))
defer cancel()
resp, err := ctxhttp.Do(ctx, otelhttp.DefaultClient, req)
if err != nil {