Skip to content

Commit

Permalink
Add a function to add a new scope field from an existing Sentry scope (
Browse files Browse the repository at this point in the history
…#29)

This allows to use breadcrumbs while keeping the information tied to
non-default hubs by doing `log.With(zapsentry.NewScopeFromScope(hub.Scope()))`
(e.g. when using https: //docs.sentry.io/platforms/go/guides/http/).
  • Loading branch information
jeandeaual authored Jul 9, 2022
1 parent aeaf8f3 commit 858a5ed
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ const (
zapSentryScopeKey = "_zapsentry_scope_"
)

func NewScope() zapcore.Field {
func NewScopeFromScope(scope *sentry.Scope) zapcore.Field {
f := zap.Skip()
f.Interface = sentry.NewScope()
f.Interface = scope
f.Key = zapSentryScopeKey

return f
}

func NewScope() zapcore.Field {
return NewScopeFromScope(sentry.NewScope())
}

func NewCore(cfg Configuration, factory SentryClientFactory) (zapcore.Core, error) {
client, err := factory()
if err != nil {
Expand Down

0 comments on commit 858a5ed

Please sign in to comment.