forked from TheZeroSlave/zapsentry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfield.go
More file actions
29 lines (23 loc) · 739 Bytes
/
Copy pathfield.go
File metadata and controls
29 lines (23 loc) · 739 Bytes
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
package zapsentry
import (
"context"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
type tagField struct {
Key string
Value string
}
func Tag(key string, value string) zap.Field {
return zap.Field{Key: key, Type: zapcore.SkipType, Interface: tagField{key, value}}
}
type ctxField struct {
Value context.Context
}
// Context adds a context to the logger.
// This can be used e.g. to pass trace information to sentry and allow linking events to their respective traces.
//
// See also https://docs.sentry.io/platforms/go/performance/instrumentation/opentelemetry/#linking-errors-to-transactions
func Context(ctx context.Context) zap.Field {
return zap.Field{Key: "context", Type: zapcore.SkipType, Interface: ctxField{ctx}}
}