Skip to content

feat: add scope context API - #1371

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

giortzisg wants to merge 1 commit into
scopes/scope-datafrom
scopes/scope-storage

Conversation

@giortzisg

@giortzisg giortzisg commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

Adds the new scope context API.

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-154

@giortzisg
giortzisg marked this pull request as ready for review July 23, 2026 08:26
Comment thread scope_context.go Outdated
Comment thread sentry.go
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 0bb8a70 to 8ce983c Compare July 23, 2026 08:45
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 8ce983c to 3ce9717 Compare July 30, 2026 20:45
Comment thread scope_context.go
Comment thread sentry.go
}

// WithScope is a shorthand for CurrentHub().WithScope.
func WithScope(f func(scope *Scope)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are only these methods removed here and not the others? can you add a short summary of the breaking changes in the PR description?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, please also adjust the PR title to feat! so that Craft identifies this as a breaking change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Didn't remove the rest because of test usage. Functionality of the scope propagation on ctx isn't finalized on this PR so can't really swap, but it's a fair argument. I'll re-add this and remove everything with all Hub functionality on the final PR to only have public API breaking changes under a single part of the stack.

@szokeasaurusrex szokeasaurusrex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm! Left a few minor comments and a question

Comment thread scope.go Outdated
Comment thread scope.go Outdated
Comment thread sentry.go
}

// WithScope is a shorthand for CurrentHub().WithScope.
func WithScope(f func(scope *Scope)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, please also adjust the PR title to feat! so that Craft identifies this as a breaking change

@giortzisg giortzisg changed the title feat: add scope context API feat!: add scope context API Aug 4, 2026
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 3ce9717 to 24cbd32 Compare August 4, 2026 15:02
Comment thread scope_context.go
Comment thread scope_context.go
@giortzisg giortzisg changed the title feat!: add scope context API feat: add scope context API Aug 10, 2026
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 1ba25e1 to 5ebf737 Compare August 10, 2026 11:28
Comment thread scope_context.go Outdated
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 5ebf737 to 14a0bf8 Compare August 10, 2026 11:36
Comment thread sentry.go Outdated
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 14a0bf8 to 01f70b4 Compare August 10, 2026 13:23
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 01f70b4 to a32c046 Compare August 13, 2026 11:40
Comment thread scope_context.go Outdated
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 7c286e0 to e747b11 Compare August 13, 2026 12:51
Comment thread scope.go Outdated
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from e747b11 to 38e8186 Compare August 24, 2026 10:16
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 38e8186 to 1b1b8fa Compare August 31, 2026 10:50
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 1b1b8fa to 098dc3a Compare September 1, 2026 09:12
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 098dc3a to d43e721 Compare September 1, 2026 12:57
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from d43e721 to 6cee5ee Compare September 4, 2026 13:11
Comment thread scope.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 client.go Outdated
Comment thread client.go
Comment thread hub.go
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from 6cee5ee to fb20939 Compare September 7, 2026 11:40

@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 client.go
@giortzisg
giortzisg force-pushed the scopes/scope-storage branch from fb20939 to 2be08f1 Compare September 7, 2026 11:49

@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 hub.go
Require context.Context across package capture APIs, bind clients and isolation scopes directly through context, and preserve last-event and propagation state on scopes. Keep Hub capture paths as a compatibility bridge while the stack migrates.

Root isolation snapshots global enrichment without inheriting an unrelated transaction. Explicit context spans retain their transaction fallback, and clearing enrichment preserves request correlation.

Package capture APIs now require context.Context and CaptureOption values. This replaces the old direct client capture signatures, RecoverWithContext, CapturePanic, EventFromMessage, EventFromException, EventFromCheckIn, and EventModifier APIs.
@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

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

Comment thread scope.go
return event
processors := scope.eventProcessors[:len(scope.eventProcessors):len(scope.eventProcessors)]
scope.mu.RUnlock()
return processors

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Scope lock leaked on apply panic

Medium Severity

applyToEvent now unlocks scope.mu by hand instead of with defer. A panic while copying scope data leaves that read lock held, so later captures on the same scope can hang. GlobalScope is process-wide, so a recovered panic during a background capture can stall all subsequent events.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b73b50f. 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

3 participants