Skip to content

Commit b3c81f0

Browse files
Added details on IsGlobalModeEnabled to Hubs and Scopes docs (#11426)
1 parent 3e79e47 commit b3c81f0

File tree

3 files changed

+42
-20
lines changed
  • docs/platforms

3 files changed

+42
-20
lines changed

docs/platforms/dotnet/common/enriching-events/scopes/index.mdx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,20 @@ time to modify data stored on the scope. This is useful for doing things like
3636

3737
<Alert>
3838

39-
If you are very curious about how thread locality works: On platforms such as .NET
40-
or on Python 3.7 and later we will use "ambient data" to have either the hub flow
41-
with your code or the hub is already a singleton that internally manages the scope.
42-
43-
Effectively this means that when you spawn a task in .NET and the execution flow is
44-
not suppressed all the context you have bound to the scope in Sentry will flow along.
45-
If however you suppress the flow, you get new scope data.
39+
If you are very curious about how thread locality works for scope data, in .NET there
40+
are two modes for managing "ambient data". Usuaully Sentry will automatically choose the
41+
most appropriate mode for your application type. However this can be overridden by
42+
setting [`SentryOptions.IsGlobalModeEnabled`](../../configuration/options/#is-global-mode-enabled) manually.
43+
44+
If global mode is disabled (appropriate for most server based applications), the
45+
ambient scope data is stored as an `AsyncLocal` and so it will flow with the execution
46+
context. Stephen Toub's blog post on [ExecutionContext vs SynchronizationContext](https://devblogs.microsoft.com/pfxteam/executioncontext-vs-synchronizationcontext/)
47+
explains that concept in more detail.
48+
49+
If global mode is enabled (appropriate for desktop applications), ambient scope data is
50+
stored as a Singleton and available globally. This means you can set context (such as
51+
the user logged into the application) once and it will be sent with all events, regardless
52+
of whether the event was captured on the UI thread or a background thread.
4653

4754
</Alert>
4855

docs/platforms/powershell/enriching-events/scopes/index.mdx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,20 @@ time to modify data stored on the scope. This is useful for doing things like
3636

3737
<Alert>
3838

39-
If you are very curious about how thread locality works: On platforms such as .NET
40-
or on Python 3.7 and later we will use "ambient data" to have either the hub flow
41-
with your code or the hub is already a singleton that internally manages the scope.
42-
43-
Effectively this means that when you spawn a task in .NET and the execution flow is
44-
not suppressed all the context you have bound to the scope in Sentry will flow along.
45-
If however you suppress the flow, you get new scope data.
39+
If you are very curious about how thread locality works for scope data, in .NET there
40+
are two modes for managing "ambient data". Usuaully Sentry will automatically choose the
41+
most appropriate mode for your application type. However this can be overridden by
42+
setting [`SentryOptions.IsGlobalModeEnabled`](../../configuration/options/#is-global-mode-enabled) manually.
43+
44+
If global mode is disabled (appropriate for most server based applications), the
45+
ambient scope data is stored as an `AsyncLocal` and so it will flow with the execution
46+
context. Stephen Toub's blog post on [ExecutionContext vs SynchronizationContext](https://devblogs.microsoft.com/pfxteam/executioncontext-vs-synchronizationcontext/)
47+
explains that concept in more detail.
48+
49+
If global mode is enabled (appropriate for desktop applications), ambient scope data is
50+
stored as a Singleton and available globally. This means you can set context (such as
51+
the user logged into the application) once and it will be sent with all events, regardless
52+
of whether the event was captured on the UI thread or a background thread.
4653

4754
</Alert>
4855

docs/platforms/unity/enriching-events/scopes/index.mdx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,21 @@ time to modify data stored on the scope. This is useful for doing things like
3535
[modifying the context](../context/).
3636

3737
<Alert>
38-
If you are very curious about how thread locality works: On platforms such as .NET
39-
or on Python 3.7 and later we will use "ambient data" to have either the hub flow
40-
with your code or the hub is already a singleton that internally manages the scope.
4138

42-
Effectively this means that when you spawn a task in .NET and the execution flow is
43-
not suppressed all the context you have bound to the scope in Sentry will flow along.
44-
If however you suppress the flow, you get new scope data.
39+
If you are very curious about how thread locality works for scope data, in .NET there
40+
are two modes for managing "ambient data". Usuaully Sentry will automatically choose the
41+
most appropriate mode for your application type. However this can be overridden by
42+
setting [`SentryOptions.IsGlobalModeEnabled`](../../configuration/options/#is-global-mode-enabled) manually.
43+
44+
If global mode is disabled (appropriate for most server based applications), the
45+
ambient scope data is stored as an `AsyncLocal` and so it will flow with the execution
46+
context. Stephen Toub's blog post on [ExecutionContext vs SynchronizationContext](https://devblogs.microsoft.com/pfxteam/executioncontext-vs-synchronizationcontext/)
47+
explains that concept in more detail.
48+
49+
If global mode is enabled (appropriate for desktop applications), ambient scope data is
50+
stored as a Singleton and available globally. This means you can set context (such as
51+
the user logged into the application) once and it will be sent with all events, regardless
52+
of whether the event was captured on the UI thread or a background thread.
4553

4654
</Alert>
4755

0 commit comments

Comments
 (0)