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 on lines +309 to +311
boundClient: scope.boundClient,
eventProcessors: scope.eventProcessors[:len(scope.eventProcessors):len(scope.eventProcessors)],
scopeData: data.clone(),

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.

[question] does the reordering of scopeData after eventProcessors change the code's behavior? Or is it simply a formatting change?

I am just trying to understand why this change is being made here.

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.

Doesn't affect code behavior. This diff is just adding scope.boundClient.

Comment thread scope.go Outdated
Comment on lines +24 to +25
// Clearing or cloning the scope only affects the underlying data. To set a new
// client or event processor, SetClient or AddEventProcessor should be used.

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.

l: I find this paragraph to be slightly unclear. What is meant by the "underlying data" in this context?

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.

It's everything under scopeData, which is essentially all the data set by the user. Not really sure how to call this.

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 a32c046 to 7c286e0 Compare August 13, 2026 11:48
@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

@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.

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 2be08f1. Configure here.

Comment thread scope.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.

BREAKING CHANGE: Package capture APIs now require context.Context and CaptureOption values. Direct Client capture methods, RecoverWithContext, CapturePanic, EventFromMessage, EventFromException, EventFromCheckIn, and EventModifier are removed.
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