Skip to content

Commit

Permalink
ref: Align SetContext (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric authored Mar 20, 2023
1 parent 27e50ad commit bfe5e9a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ func StartSpan(ctx context.Context, operation string, options ...SpanOption) *Sp
ctx: context.WithValue(ctx, spanContextKey{}, &span),
parent: parent,
isTransaction: !hasParent,

contexts: make(map[string]Context),
}

if hasParent {
Expand Down Expand Up @@ -241,7 +239,13 @@ func (s *Span) SetData(name, value string) {
s.Data[name] = value
}

// SetContext sets a context on the span. It is recommended to use SetContext instead of
// accessing the contexts map directly as SetContext takes care of initializing the map
// when necessary.
func (s *Span) SetContext(key string, value Context) {
if s.contexts == nil {
s.contexts = make(map[string]Context)
}
s.contexts[key] = value
}

Expand Down

0 comments on commit bfe5e9a

Please # to comment.