You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/android/configuration/options.mdx
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,6 +192,14 @@ _(New in version 6.0.0)_
192
192
193
193
</ConfigKey>
194
194
195
+
<ConfigKeyname="force-init">
196
+
197
+
Set this boolean to `true` to force a call to `SentryAndroid.init` to re-initialize the SDK, even if the SDK has already been initialized with high priority.
198
+
199
+
_(New in version 8.0.0)_
200
+
201
+
</ConfigKey>
202
+
195
203
## Integration Configuration
196
204
197
205
For many platform SDKs integrations can be configured alongside it. On some platforms that happen as part of the `init()` call, in some others, different patterns apply.
@@ -258,20 +266,14 @@ Default: set to `android.content.Context.getCacheDir()/sentry`.
258
266
259
267
</ConfigKey>
260
268
261
-
<ConfigKeyname="shutdown-timeout">
269
+
<ConfigKeyname="shutdown-timeout-millis">
262
270
263
-
Controls how many seconds to wait before shutting down. Sentry SDKs send events from a background queue. This queue is given a certain amount to drain pending events. The default is SDK specific but typically around two seconds. Setting this value too low may cause problems for sending events from command line applications. Setting the value too high will cause the application to block for a long time for users experiencing network connectivity problems.
271
+
Controls how many seconds to wait before shutting down. Sentry SDKs send events from a background queue. This queue is given a certain amount to drain pending events. The default is SDK specific but typically around two seconds. Setting this value too low may cause problems for sending events from the application. Setting the value too high will cause the application to block for a long time for users experiencing network connectivity problems.
264
272
265
273
</ConfigKey>
266
274
267
275
## Tracing Options
268
276
269
-
<ConfigKeyname="enable-tracing">
270
-
271
-
A boolean value, if true, transactions and trace data will be generated and captured. This will set the <PlatformIdentifiername="traces-sample-rate" /> to the recommended default of 1.0 if <PlatformIdentifiername="traces-sample-rate" /> is not defined. Note that <PlatformIdentifiername="traces-sample-rate" /> and <PlatformIdentifiername="traces-sampler" /> take precedence over this option.
272
-
273
-
</ConfigKey>
274
-
275
277
<ConfigKeyname="traces-sample-rate">
276
278
277
279
A number between 0 and 1, controlling the percentage chance a given transaction will be sent to Sentry. (0 represents 0% while 1 represents 100%.) Applies equally to all transactions created in the app. Either this or <PlatformIdentifiername="traces-sampler" /> must be defined to enable tracing.
Copy file name to clipboardExpand all lines: docs/platforms/android/configuration/shared-environments.mdx
+16-9Lines changed: 16 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,11 +16,12 @@ When setting up Sentry inside a library, the consuming app could use the Sentry
16
16
17
17
</Note>
18
18
19
-
In order to not conflict with other Sentry instances, you should use the `Hub` API to create a new instance of Sentry.
20
-
The Hub API works the same way as the global Sentry instance, but it is not global and can be used within your component. If you want to capture uncaught exceptions, you can use the `UncaughtExceptionHandlerIntegration` to capture them. As this will capture all uncaught exceptions within an app, you should use the `BeforeSendCallback` to only accept events that are relevant for your SDK.
19
+
In order to not conflict with other Sentry instances, you should use the `Scopes` API to create a new instance of Sentry.
20
+
The Scopes API works the same way as the global Sentry instance, but it is not global and can be used within your component. If you want to capture uncaught exceptions, you can use the `UncaughtExceptionHandlerIntegration` to capture them. As this will capture all uncaught exceptions within an app, you should use the `BeforeSendCallback` to only accept events that are relevant for your SDK.
Copy file name to clipboardExpand all lines: docs/platforms/android/enriching-events/scopes/index.mdx
+60-27Lines changed: 60 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,46 +1,79 @@
1
1
---
2
-
title: Scopes and Hubs
2
+
title: Scopes
3
3
description: "SDKs will typically automatically manage the scopes for you in the framework integrations. Learn what a scope is and how you can use it to your advantage."
4
4
---
5
5
6
6
When an event is captured and sent to Sentry, SDKs will merge that event data with extra
7
7
information from the current scope. SDKs will typically automatically manage the scopes
8
8
for you in the framework integrations and you don't need to think about them. However,
9
-
you should know what a scope is and how you can use it for your advantage.
9
+
you should know what a scope is and how you can use it to your advantage.
10
10
11
-
## What's a Scope, What's a Hub
11
+
## What's a Scope?
12
12
13
-
You can think of the hub as the central point that our SDKs use to route an
14
-
event to Sentry. When you call `init()` a hub is created and a client and a
15
-
blank scope are created on it. That hub is then associated with the current
16
-
thread and will internally hold a stack of scopes.
17
-
18
-
The scope will hold useful information that should be sent along with the
19
-
event. For instance [contexts](../context/) or
13
+
Scopes hold useful information that gets sent along with the
14
+
event. For instance, [contexts](../context/) and
20
15
[breadcrumbs](../breadcrumbs/) are stored on
21
-
the scope. When a scope is pushed, it inherits all data from the parent scope
22
-
and when it pops all modifications are reverted.
16
+
the scope. When a scope is forked, it inherits all data from its parent scope.
17
+
18
+
## How Scopes Work
19
+
20
+
Scopes are basically stacks of data that are attached to events. When an event is captured, the SDK will merge the data from the active scopes into the event. This allows you to attach data to events that is relevant to the context in which the event was captured.
21
+
22
+
When you call a global function such as `Sentry.captureException`, Sentry automatically discovers the active scopes and applies them when capturing the event.
23
+
24
+
## Different Kinds of Scopes
25
+
26
+
The Sentry SDK has three different kinds of scopes:
27
+
28
+
-[Global scope](#global-scope)
29
+
-[Isolation scope](#isolation-scope)
30
+
-[Current scope](#current-scope)
31
+
32
+
The Android SDK does not fork scopes on its own so you may set data on any of the scopes. The Android SDK writes to [current scope](#current-scope) by default when using top level API like `Sentry.setTag`.
33
+
34
+
### Global Scope
35
+
36
+
The global scope is applied to _all_ events, no matter where they originate. You can use it to store data that should apply to all events, such as environmental information.
37
+
38
+
### Isolation Scope
39
+
40
+
The isolation scope is used to isolate events from each other. For example, each request in a web server might get its own isolation scope, so that events from one request don't interfere with events from another request.
41
+
42
+
### Current Scope
43
+
44
+
The current scope is the local scope that is currently active. You can modify the current scope via `Sentry.configureScope(scope -> { ... })`.
45
+
46
+
## How Scope Data is Applied to Events
47
+
48
+
Global scope, isolation scope, and current scope are combined before an event (like an error or transaction) gets sent to Sentry.
49
+
In most cases, setting something on current scope replaces the same thing that may have been set on isolation or global scope. If it hasn't been set on current scope, the value on isolation scope takes precedence over the one from global scope. If there also isn't any value on isolation scope, the one from global scope is used if present.
50
+
51
+
Note, there are exceptions to this, where values from all scopes are merged. This is the case for breadcrumbs, tags, extras, contexts, attachments, and event processors.
23
52
24
-
The default SDK integrations will push and pop scopes intelligently. For
25
-
instance web framework integrations will create and destroy scopes around your
The most useful operation when working with scopes is the <PlatformIdentifiername="configure-scope" /> function. It can be used to reconfigure the current scope.
76
+
There are two main ways to interact with the scope. You can modify the current scope via `Sentry.configureScope(scope -> { ... })` and use setters on the resulting scope, or you can use global methods like `Sentry.setTag()` directly, which will set on the respective scope under the hood (which will be the isolation scope).
44
77
45
78
You can, for instance, add custom tags or inform Sentry about the currently authenticated user.
46
79
@@ -53,7 +86,7 @@ You can also apply this configuration when unsetting a user at logout:
Copy file name to clipboardExpand all lines: docs/platforms/java/common/configuration/options.mdx
+9-13Lines changed: 9 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,6 +162,14 @@ _(New in version 6.0.0)_
162
162
163
163
</ConfigKey>
164
164
165
+
<ConfigKeyname="force-init">
166
+
167
+
Set this boolean to `true` to force a call to `Sentry.init` to re-initialize the SDK, even if the SDK has already been initialized by a high priority integration.
168
+
169
+
_(New in version 8.0.0)_
170
+
171
+
</ConfigKey>
172
+
165
173
<ConfigKeyname="enable-backpressure-handling">
166
174
167
175
Set this boolean to `false` to disable automatic downsampling of transactions while the system is under load. The `tracesSampleRate` is halved for every failing health check up to 10 times, (roughly 0.001% of the original `tracesSampleRate`). Any positive health check will reset `tracesSampleRate` to its original value. Health checks run in the background every 10 seconds, checking for queue drops and rate limiting. Note: Starting with version 7.8.0 backpressure handling has changed from opt-in to opt-out.
@@ -221,20 +229,14 @@ When set, a proxy can be configured that should be used for outbound requests. T
221
229
222
230
</ConfigKey>
223
231
224
-
<ConfigKeyname="shutdown-timeout">
232
+
<ConfigKeyname="shutdown-timeout-millis">
225
233
226
234
Controls how many seconds to wait before shutting down. Sentry SDKs send events from a background queue. This queue is given a certain amount to drain pending events. The default is SDK specific but typically around two seconds. Setting this value too low may cause problems for sending events from command line applications. Setting the value too high will cause the application to block for a long time for users experiencing network connectivity problems.
227
235
228
236
</ConfigKey>
229
237
230
238
## Tracing Options
231
239
232
-
<ConfigKeyname="enable-tracing">
233
-
234
-
A boolean value, if true, transactions and trace data will be generated and captured. This will set the `traces-sample-rate` to the recommended default of 1.0 if `traces-sample-rate` is not defined. Note that `traces-sample-rate` and `traces-sampler` take precedence over this option.
235
-
236
-
</ConfigKey>
237
-
238
240
<ConfigKeyname="traces-sample-rate">
239
241
240
242
A number between 0 and 1, controlling the percentage chance a given transaction will be sent to Sentry. (0 represents 0% while 1 represents 100%.) Applies equally to all transactions created in the app. Either this or <PlatformIdentifiername="traces-sampler" /> must be defined to enable tracing.
@@ -247,12 +249,6 @@ A function responsible for determining the percentage chance a given transaction
247
249
248
250
</ConfigKey>
249
251
250
-
<ConfigKeyname="tracing-origins">
251
-
252
-
An optional property that configures which downstream services receive the `sentry-trace` header attached to HTTP requests. It contains a list of URLs or regex against which URLs are matched. If not set, the `sentry-trace` header is attached to every request executed from an instrumented client.
253
-
254
-
</ConfigKey>
255
-
256
252
<ConfigKeyname="trace-propagation-targets">
257
253
258
254
An optional property that controls which downstream services receive tracing data, in the form of a `sentry-trace` and a `baggage` header attached to any outgoing HTTP requests.
0 commit comments