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 @@ import (
"bytes"
"context"
"errors"
"fmt"
"net/http"
"net/url"
"os"
@@ -97,7 +98,7 @@ func (t *Tracker) SendEvent(ctx context.Context, e Event) error {
if err != nil {
return err
}
ctx, cancel := context.WithTimeout(req.Context(), HTTP_TIMEOUT)
ctx, cancel := context.WithTimeoutCause(req.Context(), HTTP_TIMEOUT, fmt.Errorf("tracker request timeout (%f)s exceeded", HTTP_TIMEOUT.Seconds()))
defer cancel()
req = req.WithContext(ctx)