Skip to content

ref: move static data from Enricher onto the root Scope #5892

Not planned

Description

@jamescrosswell

Problem

The SDK has separate paths for adding its default data to telemetry:

  • Events and transactions go through Enricher.Apply at send time (MainSentryEventProcessor and SentryClient).
  • Check-ins go through a separate Enricher.Apply(SentryCheckIn) overload.
  • Logs and metrics use SetDefaultAttributes.

Much of what Enricher sets doesn't change after init, but it is recomputed for every event. Suggested here as a follow-up to #4882, the idea is to push this data onto the root scope at init, so it reaches telemetry the same way as other scope data.

Current state and target

Data set by Enricher Changes after init? Target
Runtime and OS contexts No Root scope
SDK name, version and package No Root scope
Release, distribution, environment No Root scope
Default tags No Root scope
App start time, device boot time No Root scope
Environment.UserName, {{auto}} IP address No, but depends on whether the user is already set To decide
User.Id from InstallationId No Already on the root scope in global mode (GlobalRootScopeIntegration). Non-global mode still uses Enricher.
App.InForeground Yes Stays at send time

Work

  • Add a way to populate the root scope at init in both global and non-global mode.
  • Move the data that doesn't change out of Enricher.
  • Keep App.InForeground applied at send time, and decide where that code lives.
  • Decide what replaces Enricher.Apply(SentryCheckIn). SentryCheckIn isn't an IEventLike.
  • Remove Enricher if nothing is left in it.

Things to watch

  • Non-global mode. The scope stack is async-local and is created with a fresh Scope when a flow has none (SentryScopeManager.NewStack). Data pushed onto one root scope at init isn't guaranteed to be on every stack. This is why User.Id is still set in Enricher outside global mode.
  • Behaviour change. User code could see these values on the scope where they weren't set before, and code that sets them conditionally could behave differently. Earlier discussion suggested waiting for the next major version.
  • Native scope sync. Default tags are forwarded to the Android and Cocoa SDKs through the scope observer in SentrySdk.InitHub, and Enricher applies them to managed events. Moving them must not change what native crashes receive.
  • Overlapping work. DataCollection phase 2: migrate core enricher (UserInfo) #5428 also changes how Enricher handles user info.

Activity

  1. added
    .NET
    on Nov 9, 2026
  2. linear-code commented on Nov 9, 2026

    @linear-code
  3. jamescrosswell commented on Nov 26, 2026

    @jamescrosswell
    CollaboratorAuthor

    Superseded by #5671, which moved release, environment, SDK, default tags, OS and runtime contexts, and boot time into ScopeDefaults, resolved once at init. The design in #5197 chose that over setting them on the root scope, for the non-global-mode reason given above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETImprovementState: Needs Discussion

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions