Skip to content

Commit 4eaed60

Browse files
adinauerlblodermaxhovcoolguyzonegetsantry[bot]
authored
Docs updates for Java SDK v8 (#11882)
* Update Java SDK v8 deprecation removals (#11820) * Update Java SDK v8 deprecation removals * Update docs/platforms/android/configuration/options.mdx Co-authored-by: Lukas Bloder <[email protected]> --------- Co-authored-by: Lukas Bloder <[email protected]> * Add documentation on how to check-in to an environment with CheckInUtils (#11826) * Remove `enableTracing` option from Java SDK as it has been removed in v8 (#11575) * Update OpenTelemetry docs for Java v8 (#12209) * Update OTel docs for Java v8 * Apply suggestions from code review Co-authored-by: Alex Krawiec <[email protected]> --------- Co-authored-by: Alex Krawiec <[email protected]> * Document `forceInit` for Java SDK (#12260) * document forceInit option * Apply suggestions from code review Co-authored-by: Lukas Bloder <[email protected]> --------- Co-authored-by: Lukas Bloder <[email protected]> * Improve `bindToScope` docs for Java (#12263) * Improve bindToScope docs * Apply suggestions from code review Co-authored-by: Alex Krawiec <[email protected]> --------- Co-authored-by: Alex Krawiec <[email protected]> * Docs for `sentry-graphql-22` (#12259) * Duplicate docs for graphql-java v22 * link between graphql docs versions * Apply suggestions from code review Co-authored-by: Alex Krawiec <[email protected]> --------- Co-authored-by: Alex Krawiec <[email protected]> * Update platform docs for v8 and use OpenTelemetry (#12232) * Update OTel docs for Java v8 * Change platform docs for v8 and use OTel * move includes to index file * CR changes * [getsentry/action-github-commit] Auto commit * close ConfigKey tag * replace link * fix link * Update Android SDK "Using Sentry within an SDK" section for Java SDK v8 (#12325) * Update Using Sentry within an SDK for v8 * Update docs/platforms/android/configuration/shared-environments.mdx Co-authored-by: Lukas Bloder <[email protected]> --------- Co-authored-by: Lukas Bloder <[email protected]> * Add documentation on setting SpanKind and capture HttpHeaders with OTEL (#12328) * wip add docs for capturing http headers as well as manual instrumentation using opentelemetry * Update docs/platforms/java/common/tracing/instrumentation/opentelemetry.mdx Co-authored-by: Alexander Dinauer <[email protected]> --------- Co-authored-by: Alexander Dinauer <[email protected]> * Replace `Hub` docs with `Scopes` (#12377) * Replace hub docs with scopes docs * Apply suggestions from code review Co-authored-by: Alex Krawiec <[email protected]> Co-authored-by: Lukas Bloder <[email protected]> * Apply suggestions from code review Co-authored-by: Lukas Bloder <[email protected]> * Update docs/platforms/android/enriching-events/scopes/index.mdx * duplicate java into android * Update docs/platforms/android/enriching-events/scopes/index.mdx --------- Co-authored-by: Alex Krawiec <[email protected]> Co-authored-by: Lukas Bloder <[email protected]> --------- Co-authored-by: Lukas Bloder <[email protected]> Co-authored-by: Max Hovens <[email protected]> Co-authored-by: Alex Krawiec <[email protected]> Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 49283ad commit 4eaed60

File tree

50 files changed

+815
-382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+815
-382
lines changed

docs/platforms/android/configuration/options.mdx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ _(New in version 6.0.0)_
192192

193193
</ConfigKey>
194194

195+
<ConfigKey name="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+
195203
## Integration Configuration
196204

197205
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`.
258266

259267
</ConfigKey>
260268

261-
<ConfigKey name="shutdown-timeout">
269+
<ConfigKey name="shutdown-timeout-millis">
262270

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

265273
</ConfigKey>
266274

267275
## Tracing Options
268276

269-
<ConfigKey name="enable-tracing">
270-
271-
A boolean value, if true, transactions and trace data will be generated and captured. This will set the <PlatformIdentifier name="traces-sample-rate" /> to the recommended default of 1.0 if <PlatformIdentifier name="traces-sample-rate" /> is not defined. Note that <PlatformIdentifier name="traces-sample-rate" /> and <PlatformIdentifier name="traces-sampler" /> take precedence over this option.
272-
273-
</ConfigKey>
274-
275277
<ConfigKey name="traces-sample-rate">
276278

277279
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 <PlatformIdentifier name="traces-sampler" /> must be defined to enable tracing.

docs/platforms/android/configuration/shared-environments.mdx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ When setting up Sentry inside a library, the consuming app could use the Sentry
1616

1717
</Note>
1818

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

2222
```kotlin
23-
import io.sentry.Hub
23+
import io.sentry.Scope
24+
import io.sentry.Scopes
2425
import io.sentry.SentryOptions
2526
import io.sentry.SentryOptions.BeforeSendCallback
2627
import io.sentry.UncaughtExceptionHandlerIntegration
@@ -40,21 +41,27 @@ val options = SentryOptions().apply {
4041

4142
}
4243

43-
val hub = Hub(options)
44+
val globalScope = Scope(options);
45+
val isolationScope = Scope(options);
46+
val scope = Scope(options);
47+
48+
globalScope.bindClient(new SentryClient(options));
49+
50+
Scopes scopes = Scopes(scope, isolationScope, globalScope, "MySentry.init");
4451

4552
val integration = UncaughtExceptionHandlerIntegration()
4653
options.addIntegration(integration)
47-
integration.register(hub, options)
54+
integration.register(scopes, options)
4855
```
4956

50-
Once the Hub is configured, you can use it to capture events:
57+
Once the `Scopes` are configured, you can use them to capture events:
5158

5259
```kotlin
53-
hub.captureException(IllegalStateException("Example Exception"))
60+
scopes.captureException(IllegalStateException("Example Exception"))
5461
```
5562

56-
If your SDK can be opened and closed multiple times, you should also close the Hub when you are done with it:
63+
If your SDK can be opened and closed multiple times, you should also close the `Scopes` when you are done:
5764

5865
```kotlin
59-
hub.close()
66+
scopes.close()
6067
```

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

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,79 @@
11
---
2-
title: Scopes and Hubs
2+
title: Scopes
33
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."
44
---
55

66
When an event is captured and sent to Sentry, SDKs will merge that event data with extra
77
information from the current scope. SDKs will typically automatically manage the scopes
88
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.
1010

11-
## What's a Scope, What's a Hub
11+
## What's a Scope?
1212

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
2015
[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.
2352

24-
The default SDK integrations will push and pop scopes intelligently. For
25-
instance web framework integrations will create and destroy scopes around your
26-
routes or controllers.
53+
```java
54+
Sentry.configureScope(ScopeType.GLOBAL, scope -> {
55+
scope.setExtra("shared", "global");
56+
scope.setExtra("global", "data");
57+
});
2758

28-
## How the Scope and Hub Work
59+
Sentry.configureScope(ScopeType.ISOLATION, scope -> {
60+
scope.setExtra("shared", "isolation");
61+
scope.setExtra("isolation", "data");
62+
});
2963

30-
As you start using an SDK, a scope and hub are automatically created for you out
31-
of the box. It's unlikely that you'll interact with the hub directly unless you're
32-
writing an integration or you want to create or destroy scopes. Scopes, on the
33-
other hand are more user facing. You can call <PlatformIdentifier name="configure-scope" /> at any point in
34-
time to modify data stored on the scope. This is useful for doing things like
35-
[modifying the context](../context/).
64+
Sentry.configureScope(ScopeType.CURRENT, scope -> {
65+
scope.setExtra("shared", "current");
66+
scope.setExtra("current", "data");
67+
});
3668

37-
When you call a global function such as <PlatformIdentifier name="capture-event" /> internally Sentry
38-
discovers the current hub and asks it to capture an event. Internally the hub will
39-
then merge the event with the topmost scope's data.
69+
Sentry.captureException(new Exception("my error"));
70+
// --> Will have the following extra:
71+
// { shared: 'current', global: 'data', isolation: 'data', current: 'data' }
72+
```
4073

4174
## Configuring the Scope
4275

43-
The most useful operation when working with scopes is the <PlatformIdentifier name="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).
4477

4578
You can, for instance, add custom tags or inform Sentry about the currently authenticated user.
4679

@@ -53,7 +86,7 @@ You can also apply this configuration when unsetting a user at logout:
5386
<PlatformContent includePath="enriching-events/scopes/scope-synchronization" />
5487

5588
To learn what useful information can be associated with scopes see
56-
[the context documentation](../context/).
89+
[context](../context/), [tags](../tags), [users](../identify-user) and [breadcrumbs](../breadcrumbs/).
5790

5891
## Local Scopes
5992

docs/platforms/java/common/configuration/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,18 @@ sentry.traces-sample-rate=0.2
265265

266266
### Tracing Origins
267267

268-
To set tracing origins, use the `tracing-origins` option:
268+
To set tracing origins, use the `trace-propagation-targets` option:
269269

270270
```properties {tabTitle:sentry.properties}
271-
tracing-origins=localhost,^(http|https)://api\\..*$
271+
trace-propagation-targets=localhost,^(http|https)://api\\..*$
272272
```
273273

274274
```properties {tabTitle:environment variable}
275-
SENTRY_TRACING_ORIGINS=localhost,^(http|https)://api\\..*$
275+
SENTRY_TRACE_PROPAGATION_TARGETS=localhost,^(http|https)://api\\..*$
276276
```
277277

278278
```properties {tabTitle:system property}
279-
sentry.tracing-origins=localhost,^(http|https)://api\\..*$
279+
sentry.trace-propagation-targets=localhost,^(http|https)://api\\..*$
280280
```
281281

282282
### Debug

docs/platforms/java/common/configuration/options.mdx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ _(New in version 6.0.0)_
162162

163163
</ConfigKey>
164164

165+
<ConfigKey name="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+
165173
<ConfigKey name="enable-backpressure-handling">
166174

167175
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
221229

222230
</ConfigKey>
223231

224-
<ConfigKey name="shutdown-timeout">
232+
<ConfigKey name="shutdown-timeout-millis">
225233

226234
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.
227235

228236
</ConfigKey>
229237

230238
## Tracing Options
231239

232-
<ConfigKey name="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-
238240
<ConfigKey name="traces-sample-rate">
239241

240242
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 <PlatformIdentifier name="traces-sampler" /> must be defined to enable tracing.
@@ -247,12 +249,6 @@ A function responsible for determining the percentage chance a given transaction
247249

248250
</ConfigKey>
249251

250-
<ConfigKey name="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-
256252
<ConfigKey name="trace-propagation-targets">
257253

258254
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

Comments
 (0)