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
28
29
30
31
32
33
34
35
36
37
|
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...)
}
// CaptureErrWithStackTrace calls labkit's errortracking function and attaches the stack trace and any additional fields
func CaptureErrWithStackTrace(err error, fields ...errortracking.CaptureOption) {
opts := append(
fields,
errortracking.WithStackTrace(),
)
errortracking.Capture(err, opts...)
}
|