Skip to content

fix: safe concurrent access for span and scope#1285

Merged
giortzisg merged 6 commits intomasterfrom
fix/preserialize-span-tags
Apr 28, 2026
Merged

fix: safe concurrent access for span and scope#1285
giortzisg merged 6 commits intomasterfrom
fix/preserialize-span-tags

Conversation

@giortzisg
Copy link
Copy Markdown
Contributor

@giortzisg giortzisg commented Apr 27, 2026

Description

This PR makes tracing concurrent access dureing capture and serialization safe. It adds:

  • child spans are made serialization safe
  • span.traceContext now returns a locked snapshot of span.Data
  • hub trace and baggage getters now access span and propagation context under locks.

Issues

  • resolves: SDK-1186
  • resolves: SDK-1187
  • resolves: SDK-1191
Changelog Entry Instructions

To add a custom changelog entry, uncomment the section above. Supports:

  • Single entry: just write text
  • Multiple entries: use bullet points
  • Nested bullets: indent 4+ spaces

For more details: custom changelog entries

Reminders

This adds a MakeSerializationSafe method on spans for safely cloning
tags and data fields.
@giortzisg giortzisg requested a review from Litarnus April 27, 2026 13:11
@giortzisg giortzisg self-assigned this Apr 27, 2026
@giortzisg giortzisg changed the title fix: preserialize span tags and data fix: safe concurrent access for span and scope Apr 28, 2026
Comment thread tracing.go Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 599f01b. Configure here.

Comment thread tracing.go
Copy link
Copy Markdown

@Litarnus Litarnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just a small 🚲

Comment thread tracing.go Outdated
// traceContextLocked is the lock-free variant of traceContext.
//
// This is supposed to be used only when span Finish() was already called.
func (s *Span) traceContextLocked() *TraceContext {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is a bit misleading I think. I would expect this to be the version that calls mu.RLock(). Maybe it would be better to call it traceContextLockFree?

@giortzisg giortzisg merged commit 79947a7 into master Apr 28, 2026
15 checks passed
@giortzisg giortzisg deleted the fix/preserialize-span-tags branch April 28, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants