Skip to content

feat!: move tracing to rely on ctx - #1379

Open
giortzisg wants to merge 1 commit into
scopes/scope-mergefrom
scopes/context-tracing
Open

giortzisg wants to merge 1 commit into
scopes/scope-mergefrom
scopes/context-tracing

Conversation

@giortzisg

@giortzisg giortzisg commented Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Modify existing tracing and propagation behavior to rely on context.Context. Tracing now resolves state from context rather than hubs. This includes a breaking change on ContinueTrace removing the need for a hub to be passed.

#skip-changelog

Issues

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

@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from 5562df0 to 0e6bf84 Compare July 30, 2026 20:45
@linear-code

linear-code Bot commented Aug 3, 2026

Copy link
Copy Markdown

GO-154

@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from 0e6bf84 to 09cf02b Compare August 4, 2026 15:25
@giortzisg giortzisg closed this Aug 4, 2026
@giortzisg giortzisg reopened this Aug 4, 2026
@giortzisg
giortzisg changed the base branch from scopes/context-capture to scopes/context-propagation-api August 4, 2026 15:37
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from 09cf02b to 388298c Compare August 4, 2026 15:42
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from 388298c to 569c73b Compare August 5, 2026 09:59
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from 569c73b to 580aec3 Compare August 10, 2026 11:36
@giortzisg
giortzisg changed the base branch from scopes/context-propagation-api to scopes/context-capture August 13, 2026 08:34
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from 580aec3 to 75a6927 Compare August 24, 2026 07:53
@giortzisg
giortzisg marked this pull request as ready for review August 24, 2026 07:54
Comment thread hub.go Outdated
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from 75a6927 to bee39bc Compare August 24, 2026 10:17
Comment thread hub.go Outdated
Comment thread tracing.go Outdated
@giortzisg
giortzisg removed this pull request from stack #1420 September 18, 2026 11:17
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from 645b45e to 65227ad Compare September 18, 2026 11:18
@giortzisg
giortzisg added this pull request to stack #1433 September 18, 2026 11:22
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch 2 times, most recently from e3d2c9c to cb7d5d1 Compare September 29, 2026 11:11
@giortzisg
giortzisg removed this pull request from stack #1433 September 29, 2026 11:14
@giortzisg
giortzisg added this pull request to stack #1437 September 29, 2026 11:18
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from cb7d5d1 to b3a02d5 Compare September 29, 2026 11:19
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from b3a02d5 to b968fb6 Compare October 8, 2026 12:43

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread scope.go
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from b968fb6 to c2a214f Compare October 9, 2026 08:36
@giortzisg
giortzisg removed this pull request from stack #1437 October 9, 2026 08:37
@giortzisg
giortzisg added this pull request to stack #1452 October 9, 2026 08:37
Comment thread scope.go
@giortzisg
giortzisg removed this pull request from stack #1452 October 12, 2026 14:07
@giortzisg
giortzisg added this pull request to stack #1456 October 12, 2026 14:11
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from c2a214f to b507c5a Compare October 12, 2026 15:45
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from b507c5a to f983a14 Compare October 13, 2026 15:22
@giortzisg
giortzisg force-pushed the scopes/context-tracing branch from f983a14 to 48e970e Compare October 15, 2026 17:43

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread tracing.go
Look up the client, scope, and active span from context.Context instead of the hub when starting, finishing, and sampling spans, and when attaching trace data to events, logs, and metrics. Root spans continue the trace of the scope they start on, and later roots on that scope keep its first sampling decision. Forks from WithScope start a new trace unless their parent continues one.

Freeze dynamic sampling context once for baggage, error capture, and transaction delivery. Explicit client bindings remain authoritative; unbound contexts follow Init. Keep incoming sampling decisions when recording is disabled, inherit local parent sampling before client overrides, and reject inconsistent continuation metadata without retaining a previous request's trace.

ContinueFromHeaders and ContinueFromRequest store the continued trace on the scope, and ContinueFromTrace is removed in favor of ContinueFromHeaders. StartTransaction returns the existing root without changing its context; callers reusing a transaction must retain their caller context and leave finishing to its owner.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 2 potential issues.

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 78ad682. Configure here.

Comment thread scope_context.go
scope = parent.Clone()
if !scope.continuedTrace {
scope.propagationContext = NewPropagationContext()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Forked scope keeps unrelated span

Medium Severity

WithScope replaces the cloned propagation context when continuedTrace is false, but it keeps the parent's span. A forked scope then mixes a new trace ID with the previous transaction: hub propagation still follows the old span, while spanless telemetry uses the new propagation context.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 78ad682. Configure here.

Comment thread scope.go
entries["sample_rate"] = rate
propagation.DynamicSamplingContext.Entries = entries
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shared roots record wrong sample rate

Medium Severity

keepSamplingDecision returns before storing sample_rate unless the scope DSC is already frozen and populated. Later root spans on that scope inherit only the boolean decision, and sample rewrites sampleRate to 1 or 0. Their dynamic sampling context no longer matches the rate that actually sampled the trace.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 78ad682. Configure here.

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.

Refactor scope propagation to rely on context.Context

2 participants