Skip to content

Commit

Permalink
feat(logging): support non recording span (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderPoet committed Sep 20, 2022
1 parent 598d159 commit afc948b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions logging/logrus/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,17 @@ func (h *TraceHook) Fire(entry *logrus.Entry) error {
}

span := trace.SpanFromContext(entry.Context)
if !span.IsRecording() {
return nil
}

// attach span context to log entry data fields
entry.Data[traceIDKey] = span.SpanContext().TraceID()
entry.Data[spanIDKey] = span.SpanContext().SpanID()
entry.Data[traceFlagsKey] = span.SpanContext().TraceFlags()

// non recording spans do not support modifying
if !span.IsRecording() {
return nil
}

// attach log to span event attributes
attrs := []attribute.KeyValue{
logMessageKey.String(entry.Message),
Expand Down

0 comments on commit afc948b

Please sign in to comment.