Skip to content

feat(scopes): introduce typed scopes#2139

Open
Litarnus wants to merge 2 commits into
remove-hubfrom
types-scopes
Open

feat(scopes): introduce typed scopes#2139
Litarnus wants to merge 2 commits into
remove-hubfrom
types-scopes

Conversation

@Litarnus

Copy link
Copy Markdown
Contributor

Replaces one Scope and introduces a total of 3 scopes:

  • GlobalScope - Cannot store spans but can store user data such as tags, contexts, etc
  • IsolationScope - Can store spans and is used to store request local informations
  • MergedScope - Transient scope that is the result of merging the global and isolation scope. Is considered a read-only scope and should only be used to apply data to events

Why different types of scopes?

With only one type of scopes, the burden of knowing when to merge and which one to use where is passed to the developer all the time. While it would work with any scope and it would apply some informations, it's very easy to forget to merge scopes and only get a fraction of the required informations. With having specific types, the signature can ensure that the correct scopes are being used in the correct context. It's also easier to understand intent.

The scopes also expose different methods, meaning that it's impossible to add data to a merged scope which gets discarded afterwards.

All scopes share a common ScopeData object which acts as a data storage to simplify merging/cloning. ScopeData is effectively what was the Scope before but without event specific methods

@Litarnus Litarnus changed the title Types scopes feat(scopes): introduce typed scopes Jun 24, 2026
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.

1 participant