Welcome to mirror list, hosted at ThFree Co, Russian Federation.

errortracking.go « errortracking « internal - gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8ac0fa4b9b7c202086c1c23a9a370fb5b1a9a1fd (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
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...)
}