Skip to content

Commit

Permalink
feat: add zerolog (#46) - Check spanCtx using IsValid
Browse files Browse the repository at this point in the history
  • Loading branch information
lovung committed Jan 26, 2024
1 parent 30ae4c8 commit 1a5c657
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions logging/zerolog/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ func (cfg config) getZerologHookFn() zerolog.HookFunc {
span := trace.SpanFromContext(ctx)
spanCtx := span.SpanContext()

if spanCtx.HasSpanID() {
e.Any(SpanIDKey, spanCtx.SpanID())
}
if spanCtx.HasTraceID() {
e.Any(TraceIDKey, spanCtx.TraceID())
if !spanCtx.IsValid() {
return
}

e.Any(SpanIDKey, spanCtx.SpanID())
e.Any(TraceIDKey, spanCtx.TraceID())
e.Any(TraceFlagsKey, spanCtx.TraceFlags())

if !span.IsRecording() {
Expand Down

0 comments on commit 1a5c657

Please sign in to comment.