Skip to content

Commit 1be95f0

Browse files
committed
Add request id as a tag for sentry events
1 parent 8604593 commit 1be95f0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

logger.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
const (
1515
requestIDHeader = "X-Request-Id"
1616
sentryEventIDHeader = "X-Sentry-Id"
17+
18+
sentryExtraRequestID = "request_id"
1719
)
1820

1921
// NewCore will create handy Core with sensible defaults:
@@ -75,6 +77,10 @@ func RequestLogger(logger *zap.Logger) func(next http.Handler) http.Handler {
7577
core := localCore
7678
if client != nil {
7779
hub := sentry.NewHub(client, sentry.NewScope())
80+
hub.ConfigureScope(func(scope *sentry.Scope) {
81+
scope.SetTag(sentryExtraRequestID, requestID)
82+
})
83+
7884
core = NewSentryCoreWrapper(localCore, hub, options...)
7985

8086
loggerOptions = append(loggerOptions, zap.Hooks(func(entry zapcore.Entry) error {

0 commit comments

Comments
 (0)