blob: d82674cca6eb2a237e775e7a5bc60b4971856ff9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package errortracking
import (
"net/http"
"gitlab.com/gitlab-org/labkit/errortracking"
)
// CaptureOption alias to avoid importing labkit/errortracking in internal packages
type CaptureOption = errortracking.CaptureOption
// WithField alias to avoid importing labkit/errortracking in internal packages
func WithField(key, value string) CaptureOption {
return errortracking.WithField(key, value)
}
// CaptureErrWithReqAndStackTrace calls labkit's errortracking function and attaches the request, stack trace and any additional fields
func CaptureErrWithReqAndStackTrace(err error, r *http.Request, fields ...errortracking.CaptureOption) {
opts := append(
fields,
errortracking.WithContext(r.Context()),
errortracking.WithRequest(r),
errortracking.WithStackTrace(),
)
errortracking.Capture(err, opts...)
}
|