Skip to content

feat!: add scope merging mechanism - #1373

Open
giortzisg wants to merge 1 commit into
scopes/scope-storagefrom
scopes/scope-merge
Open

giortzisg wants to merge 1 commit into
scopes/scope-storagefrom
scopes/scope-merge

Conversation

@giortzisg

@giortzisg giortzisg commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

This adds the scope merging mechanism by allocating a captureState object and copying all needed event attributes in place. This removes taking multiple scope clones on every capture.

The PR also includes breaking changes around EventModifier. The EventModifier was an agnostic modifier that was passed on ApplyToEvent. This duplicated the EventProcessor behavior and also complicated the scope merging mechanism, since we need to have a concrete *Scope type to merge the scopes. Furthermore, there is no documented behavior or signature for any EventModifier and this seems to be just the first archaic way to modify events before EventProcessor and BeforeSend hooks where a thing. Thus decided to remove this and have a concrete *Scope passed on ApplyToEvent. This behavior aligns with other sdks that pass a concrete scope.

This affects the public API with all the CaptureX methods now requiring a concrete scope to be passed, but further scope changes in the stack also change the CaptureX APIs to work with context.Context, so this change seems acceptable. Functionality isn't really removed but just shifted to BeforeSend hooks as intended.

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

@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown

GO-155

@giortzisg
giortzisg force-pushed the scopes/scope-merge branch from 8f6a8b4 to e509cb6 Compare July 23, 2026 08:45
@giortzisg
giortzisg marked this pull request as ready for review July 23, 2026 08:51
Comment thread scope.go Outdated
@giortzisg
giortzisg force-pushed the scopes/scope-merge branch from e509cb6 to 5ea0d02 Compare July 30, 2026 20:45
@giortzisg
giortzisg force-pushed the scopes/scope-merge branch from 5ea0d02 to 2905cce Compare August 4, 2026 15:25
Comment thread scope.go Outdated
@giortzisg
giortzisg force-pushed the scopes/scope-merge branch 2 times, most recently from 8b46a73 to b3bd79f Compare August 5, 2026 09:59
Comment thread scope.go Outdated
@giortzisg
giortzisg force-pushed the scopes/scope-merge branch 2 times, most recently from a32be8d to af060b8 Compare August 12, 2026 12:11
Comment thread scope.go
Comment thread scope.go Outdated
Comment thread scope.go Outdated
Comment thread scope.go Outdated
Comment thread scope.go
Comment thread metrics.go Outdated
Comment thread client.go Outdated

@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

@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
Comment thread client.go Outdated
@giortzisg
giortzisg removed this pull request from stack #1420 September 18, 2026 11:17
@giortzisg
giortzisg added this pull request to stack #1433 September 18, 2026 11:22
Comment thread scope.go Outdated
Comment thread scope.go
@giortzisg
giortzisg removed this pull request from stack #1433 September 29, 2026 11:14

@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 added this pull request to stack #1437 September 29, 2026 11:18

@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 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 993b027. Configure here.

Comment thread scope.go
Apply the single scope selected by the capture context directly to events, preserve event precedence, enforce breadcrumb limits, and run request processing and event processors after releasing the scope lock. Preserve explicitly supplied event and scope trace contexts, and retain dynamic sampling context only when it belongs to the selected trace.

Event values now take precedence over scope values during capture, context scopes replace the global scope, and scope breadcrumbs and attachments are applied before event-specific values.
@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
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.

Add scope merging for global and isolation scopes

2 participants