Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ref: Align SetContext #603

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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