Skip to content

Commit d4492cc

Browse files
merge commit
2 parents f50e57b + 7314dbe commit d4492cc

File tree

320 files changed

+18948
-292
lines changed

Some content is hidden

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

320 files changed

+18948
-292
lines changed

.craft.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ targets:
1919
maven:io.sentry:sentry:
2020
maven:io.sentry:sentry-spring:
2121
maven:io.sentry:sentry-spring-jakarta:
22+
# maven:io.sentry:sentry-spring-7:
2223
maven:io.sentry:sentry-spring-boot:
2324
maven:io.sentry:sentry-spring-boot-jakarta:
2425
maven:io.sentry:sentry-spring-boot-starter:
2526
maven:io.sentry:sentry-spring-boot-starter-jakarta:
27+
# maven:io.sentry:sentry-spring-boot-4:
28+
# maven:io.sentry:sentry-spring-boot-4-starter:
2629
maven:io.sentry:sentry-servlet:
2730
maven:io.sentry:sentry-servlet-jakarta:
2831
maven:io.sentry:sentry-logback:
@@ -59,3 +62,4 @@ targets:
5962
maven:io.sentry:sentry-android-replay:
6063
maven:io.sentry:sentry-apollo-4:
6164
maven:io.sentry:sentry-reactor:
65+
maven:io.sentry:sentry-ktor-client:

.cursor/rules/deduplication.mdc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
alwaysApply: false
3+
description: Java SDK Event deduplication
4+
---
5+
6+
# Java SDK Event deduplication
7+
8+
To avoid sending the same error multiple times, there is deduplication logic in place in the SDK.
9+
Duplicate captures can happen due to multiple integrations capturing the exception as well as additional manual calls to `Sentry.captureException`.
10+
11+
Deduplication is performed in `DuplicateEventDetectionEventProcessor` which returns `null` when it detects a duplicate event causing it to be dropped.
12+
13+
The `enableDeduplication` option can be used to opt out of deduplication. It is enabled by default.

.cursor/rules/e2e_tests.mdc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
alwaysApply: false
3+
description: Java SDK End to End Tests
4+
---
5+
6+
# Java SDK End to End Tests (System Tests)
7+
8+
The samples in the `sentry-samples` directory are used to run end to end tests against them.
9+
10+
There is a python script (`system-test-runner.py`) that can be used to run one (using `--module SAMPLE_NAME`) or all (using `--all`) system tests.
11+
12+
The script has an interactive mode (`-i`) which allows selection of test setups to execute, whether to run the tests or just prepare infrastructure for testing from IDE.
13+
14+
The tests run a mock Sentry server via `system-test-sentry-server.py`. Any system under test will then have a DSN set that reflects this local mock server like `http://502f25099c204a2fbf4cb16edc5975d1@localhost:8000/0`.
15+
By using this local DSN, the system under test sends events to the local mock server.
16+
The tests can then use `TestHelper` to assert envelopes that were received by the mock server.
17+
`TestHelper` uses HTTP requests to retrieve the JSON payload of the received events and deserialize them back to objects for easier assertion.
18+
Tests can then assert events, transactions, logs etc. similar to how they would appear in `beforeSend` and similar callbacks.
19+
20+
`TestHelper` has a lot of helper methods for asserting, e.g. by span name, log body etc.
21+
22+
The end to end tests either expect the system under test to either be running on a server or call `java -jar` to execute a CLI system under test.
23+
24+
For Spring Boot, we spin up the Spring Boot server. The tests then send requests to that server and assert what is sent to Sentry.
25+
26+
End to end tests are also executed on CI using a matrix build, as defined in `.github/workflows/system-tests-backend.yml`.
27+
28+
Some of the samples are tested in multiple ways, e.g. with OpenTelemetry Agent auto init turned on and off.

.cursor/rules/overview_dev.mdc

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
alwaysApply: true
3+
description: Sentry Java SDK - Development Rules Overview
4+
---
5+
6+
# Sentry Java SDK Development Rules
7+
8+
## Always Applied Rules
9+
10+
These rules are automatically included in every conversation:
11+
- **coding.mdc**: General contributing guidelines, build commands, and workflow rules
12+
13+
## Domain-Specific Rules (Fetch Only When Needed)
14+
15+
Use the `fetch_rules` tool to include these rules when working on specific areas:
16+
17+
### Core SDK Functionality
18+
- **`scopes`**: Use when working with:
19+
- Hub/Scope management, forking, or lifecycle
20+
- `Sentry.getCurrentScopes()`, `pushScope()`, `withScope()`
21+
- `ScopeType` (GLOBAL, ISOLATION, CURRENT)
22+
- Thread-local storage, scope bleeding issues
23+
- Migration from Hub API (v7 → v8)
24+
25+
- **`deduplication`**: Use when working with:
26+
- Duplicate event detection/prevention
27+
- `DuplicateEventDetectionEventProcessor`
28+
- `enableDeduplication` option
29+
30+
- **`offline`**: Use when working with:
31+
- Caching, envelope storage/retrieval
32+
- Network failure handling, retry logic
33+
- `AsyncHttpTransport`, `EnvelopeCache`
34+
- Rate limiting, cache rotation
35+
- Android vs JVM caching differences
36+
37+
### Integration & Infrastructure
38+
- **`opentelemetry`**: Use when working with:
39+
- OpenTelemetry modules (`sentry-opentelemetry-*`)
40+
- Agent vs agentless configurations
41+
- Span processing, sampling, context propagation
42+
- `OtelSpanFactory`, `SentrySpanExporter`
43+
- Tracing, distributed tracing
44+
45+
### Testing
46+
- **`e2e_tests`**: Use when working with:
47+
- System tests, sample applications
48+
- `system-test-runner.py`, mock Sentry server
49+
- End-to-end test infrastructure
50+
- CI system test workflows
51+
52+
## Usage Guidelines
53+
54+
1. **Start minimal**: Only include `coding.mdc` (auto-applied) for general tasks
55+
2. **Fetch on-demand**: Use `fetch_rules ["rule_name"]` when you identify specific domain work
56+
3. **Multiple rules**: Fetch multiple rules if task spans domains (e.g., `["scopes", "opentelemetry"]` for tracing scope issues)
57+
4. **Context clues**: Look for these keywords in requests to determine relevant rules:
58+
- Scope/Hub/forking → `scopes`
59+
- Duplicate/dedup → `deduplication`
60+
- OpenTelemetry/tracing/spans → `opentelemetry`
61+
- Cache/offline/network → `offline`
62+
- System test/e2e/sample → `e2e_tests`

.cursor/rules/scopes.mdc

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
alwaysApply: false
3+
description: Java SDK Hubs and Scopes
4+
---
5+
# Java SDK Hubs and Scopes
6+
7+
## `Scopes`
8+
9+
`Scopes` implements `IScopes` and manages three `Scope` instances, `global`, `isolation` and `current` scope.
10+
For some data, all three `Scope` instances are combined, for others, a certain one is used exclusively and for some we look at each scope in a certain order and use the data of the first scope that has the data set. This logic is contained in `CombinedScopeView`.
11+
Data itself is stored on `Scope` instances.
12+
`Scopes` also has a `parent` field, linking the `Scopes` it was forked off of and a `creator` String, explaining why it was forked.
13+
14+
## `Hub`
15+
16+
Up until major version 7 of the Java SDK the `IHub` interface was a central part of the SDK.
17+
In major version 8 we replaced the `IHub` interface with `IScopes`. `IHub` has been deprecated.
18+
While there is some bridging code in place to allow for easier migration, we are planning to remove it in an upcoming major.
19+
20+
## Scope Types
21+
22+
We have introduced some new Scope types in the SDK, allowing for better control over what data is attached where.
23+
Previously there was a stack of scopes that was pushed and popped.
24+
Instead we now fork scopes for a given lifecycle and then restore the previous scopes.
25+
Since Hub is gone, it is also never cloned anymore.
26+
Separation of data now happens through the different scope types while making it easier to manipulate exactly what you need without having to attach data at the right time to have it apply where wanted.
27+
28+
### Global Scope
29+
30+
Global scope is attached to all events created by the SDK.
31+
It can also be modified before Sentry.init has been called.
32+
It can be manipulated using `Sentry.configureScope(ScopeType.GLOBAL, (scope) -> { ... })`.
33+
34+
Global scope can be retrieved from `Scopes` via `getGlobalScope`. It can also be retrieved directly via `Sentry.getGlobalScope`.
35+
36+
### Isolation Scope
37+
38+
Isolation scope can be used e.g. to attach data to all events that come up while handling an incoming request.
39+
It can also be used for other isolation purposes.
40+
It can be manipulated using `Sentry.configureScope(ScopeType.ISOLATION, (scope) -> { ... })`.
41+
The SDK automatically forks isolation scope in certain cases like incoming requests, CRON jobs, Spring `@Async` and more.
42+
43+
Isolation scope can be retrieved from `Scopes` via `getIsolationScope`.
44+
45+
### Current scope
46+
47+
Current scope is forked often and data added to it is only added to events that are created while this scope is active.
48+
Data is also passed on to newly forked child scopes but not to parents.
49+
50+
Current scope can be retrieved from `Scopes` via `getScope`.
51+
52+
## Storage of `Scopes`
53+
54+
`Scopes` are stored in a `ThreadLocal` by default (NOTE: this is different for OpenTelemetry, see opentelemetry.mdc).
55+
This happens through `Sentry.scopesStorage` and `DefaultScopesStorage`.
56+
57+
The lifetime of `Scopes` in the thread local is managed by `ISentryLifecycleToken`.
58+
When the scopes are forked, they are stored into the `ThreadLocal` and a `ISentryLifecycleToken` is returned.
59+
When the `Scopes` are no longer needed, e.g. because a request is finished, `ISentryLifecycleToken.close` can be called to restore the previous state of the `ThreadLocal`.
60+
61+
## Old versions of the Java SDK
62+
63+
There were several implementations of the `IHub` interface:
64+
- `Hub` managed a stack of `Scope` instances, which were pushed and popped.
65+
- A `Hub` could be cloned, meaning there could be multiple stacks of scopes active, e.g. for two separate requests being handled in a server application.
66+
67+
### Migrating to major version 8 of the SDK
68+
69+
`IHub` has been replaced by `IScopes`
70+
`HubAdapter` has been replaced by `ScopesAdapter`
71+
`Hub.clone` should be replaced by using `pushScope` or `pushIsolationScope`
72+
`Sentry.getCurrentHub` has been replaced by `Sentry.getCurrentScopes`
73+
`Sentry.popScope` has been deprecated. Instead `close` should be called on the `ISentryLifecycleToken` returned e.g. by `pushScope`. This can also be done in a `try-with-resource` block.
74+
75+
## `globalHubMode`
76+
The SDK has a `globalHubMode` option which affects forking behaviour of the SDK.
77+
78+
Android has `globalHubMode` enabled by default.
79+
For JVM Desktop applications, `globalHubMode` can be used.
80+
For JVM Backend applications (servers) we discourage enabling `globalHubMode` since it will cause scopes to bleed into each other. This can e.g. mean that state from request A leaks into request B and events sent to Sentry contain a mix of both request A and B potentially rendering the data useless.
81+
82+
### Enabled
83+
84+
If `globalHubMode` is enabled, the SDK avoids forking scopes.
85+
86+
This means, retrieving current scopes on a thread where specific scopes do not exist yet for the thread, the root scopes are not forked but returned directly.
87+
The SDK also doesn't fork scopes when `Sentry.pushScope`, `Sentry.pushIsolation`, `Sentry.withScope` or `Sentry.withIsolationScope` are executed.
88+
89+
The suppression of forking via `globalHubMode` only applies when using `Sentry` static API or `ScopesAdapter`.
90+
In case the `Scopes` instance is accessed directly, forking will happen as if `globalHubMode` is disabled.
91+
However, while it's possible to use `Sentry.setCurrentScopes` it does not have any effect due to `Sentry.getCurrentScopes` directly returning `rootScopes` if `globalHubMode` is enabled.
92+
This means the forked scopes have to be managed manually, e.g. by keeping a reference and accessing Sentry API via the reference instead of using static API.
93+
94+
`ScopesAdapter` makes use of the static `Sentry` API internally. It allows us to access the correct scopes for the current context without passing it along explicitly. It also makes testing easier.
95+
96+
### Disabled
97+
98+
If `globalHubMode` is disabled, the SDK forks scopes freely, e.g. when:
99+
- `Sentry.getCurrentScopes()` is executed on a Thread where no specific scopes for that thread have been stored yet. In this case the SDK will fork `rootScopes` (stored in a `Sentry` static property).
100+
- `withScope` or `withIsolationScope` are executed
101+
- `pushScope` or `pushIsolationScope` are executed
102+
103+
## `defaultScopeType`
104+
105+
The `defaultScopeType` controls which `Scope` instance is being used for writing to and reading from as a default value.
106+
When using API like `Sentry.setTag` the SDK adds that tag to the default `Scope`.
107+
108+
This also ensures, customers who migrate to the latest SDK version and already have `Sentry.configureScope` invocations in place, will now write to the default `Scope` instance that was chosen.
109+
110+
The default value for `defaultScopeType` is `ISOLATION` scope for JVM and `CURRENT` scope for Android.
111+
112+
Which fields are written/read from/to `defaultScopeType` is controlled in `CombinedScopeView`.

.github/ISSUE_TEMPLATE/bug_report_java.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ body:
2424
- sentry-spring-boot-jakarta
2525
- sentry-spring-boot-starter
2626
- sentry-spring-boot-starter-jakarta
27+
- sentry-spring-boot-4
28+
- sentry-spring-boot-4-starter
2729
- sentry-spring
2830
- sentry-spring-jakarta
31+
- sentry-spring-7
2932
- sentry-logback
3033
- sentry-log4j2
3134
- sentry-graphql

.github/workflows/system-tests-backend.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ jobs:
6363
- sample: "sentry-samples-jul"
6464
agent: "false"
6565
agent-auto-init: "true"
66+
- sample: "sentry-samples-spring-boot-4"
67+
agent: "false"
68+
agent-auto-init: "true"
69+
- sample: "sentry-samples-spring-boot-4-webflux"
70+
agent: "false"
71+
agent-auto-init: "true"
72+
# - sample: "sentry-samples-spring-boot-4-opentelemetry-noagent"
73+
# agent: "false"
74+
# agent-auto-init: "true"
75+
- sample: "sentry-samples-spring-boot-4-opentelemetry"
76+
agent: "true"
77+
agent-auto-init: "true"
78+
- sample: "sentry-samples-spring-boot-4-opentelemetry"
79+
agent: "true"
80+
agent-auto-init: "false"
6681
- sample: "sentry-samples-spring-jakarta"
6782
agent: "false"
6883
agent-auto-init: "true"

.sauce/sentry-uitest-android-benchmark-lite.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ espresso:
1818

1919
suites:
2020

21-
- name: "Android 11 (api 30)"
21+
- name: "Android 15 Benchmark lite (api 35)"
2222
testOptions:
2323
clearPackageData: true
2424
useTestOrchestrator: true
2525
devices:
26-
- id: Google_Pixel_3a_real # Google Pixel 3a - api 30 (11)
26+
- name: ".*"
27+
platformVersion: "15"
2728

2829
artifacts:
2930
download:

.sauce/sentry-uitest-android-benchmark.yml

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,49 +19,34 @@ espresso:
1919
suites:
2020

2121
# Devices are chosen so that there is a high-end and a low-end device for each api level
22-
- name: "Android 12 (api 31)"
22+
- name: "Android 15 (api 35)"
2323
testOptions:
2424
clearPackageData: true
2525
useTestOrchestrator: true
2626
devices:
27-
- id: Google_Pixel_6_Pro_real_us # Google Pixel 6 Pro - api 31 (12) - high end
28-
- id: Google_Pixel_5_12_real_us # Google Pixel 5 - api 31 (12) - low end
27+
- id: Google_Pixel_9_Pro_XL_15_real_sjc1 # Google Pixel 9 Pro XL - api 35 (15) - high end
28+
- id: Samsung_Galaxy_S23_15_real_sjc1 # Samsung Galaxy S23 - api 35 (15) - mid end
29+
- id: Google_Pixel_6a_15_real_sjc1 # Google Pixel 6a - api 35 (15) - low end
2930

30-
- name: "Android 11 (api 30)"
31+
- name: "Android 14 (api 34)"
3132
testOptions:
3233
clearPackageData: true
3334
useTestOrchestrator: true
3435
devices:
35-
- id: Samsung_Galaxy_S10_Plus_11_real_us # Samsung Galaxy S10+ - api 30 (11) - high end
36-
- id: Google_Pixel_4a_real_us # Google Pixel 4a - api 30 (11) - mid end
37-
- id: Google_Pixel_3a_real # Google Pixel 3a - api 30 (11) - low end
36+
- id: Google_Pixel_9_Pro_XL_real_sjc1 # Google Pixel 9 Pro XL - api 34 (14) - high end
37+
- id: Samsung_Galaxy_A54_real_sjc1 # Samsung Galaxy A54 - api 34 (14) - low end
3838

39-
- name: "Android 10 (api 29)"
39+
- name: "Android 13 (api 33)"
4040
testOptions:
4141
clearPackageData: true
4242
useTestOrchestrator: true
4343
devices:
44-
- id: Google_Pixel_3a_XL_real # Google Pixel 3a XL - api 29 (10)
45-
- id: OnePlus_6T_real # OnePlus 6T - api 29 (10)
44+
- id: Google_Pixel_7_Pro_real_us # Google Pixel 7 Pro - api 33 (13) - high end
45+
- id: Samsung_Galaxy_A32_5G_real_sjc1 # Samsung Galaxy A32 5G - api 33 (13) - low end
4646

47-
# At the time of writing (July, 4, 2022), the market share per android version is:
48-
# 12.0 = 17.54%, 11.0 = 31.65%, 10.0 = 21.92%
49-
# Using these 3 versions we cover 71,11% of all devices out there. Currently, this is enough for benchmarking scope
50-
# Leaving these devices here in case we change mind on them
51-
# devices:
52-
# - id: Samsung_Galaxy_S8_plus_real_us # Samsung Galaxy S8+ - api 28 (9)
53-
# - id: LG_G8_ThinQ_real_us # LG G8 ThinQ - api 28 (9)
54-
# - id: OnePlus_5_real_us # OnePlus 5 - api 27 (8.1.0)
55-
# - id: LG_K30_real_us1 # LG K30 - api 27 (8.1.0)
56-
# - id: HTC_10_real_us # HTC 10 - api 26 (8.0.0)
57-
# - id: Samsung_A3_real # Samsung Galaxy A3 2017 - api 26 (8.0.0)
58-
# - id: ZTE_Axon_7_real2_us # ZTE Axon 7 - api 25 (7.1.1)
59-
# - id: Motorola_Moto_X_Play_real # Motorola Moto X Play - api 25 (7.1.1)
60-
# - id: Samsung_note_5_real_us # Samsung Galaxy Note 5 - api 24 (7.0)
61-
# - id: LG_K10_real # LG K10 - api 24 (7.0)
62-
# - id: Samsung_Galaxy_S6_Edge_Plus_real # Samsung Galaxy S6 Edge+ - api 23 (6.0.1)
63-
# - id: Samsung_Tab_E_real_us # Samsung Tab E - api 23 (6.0.1)
64-
# - id: Amazon_Kindle_Fire_HD_8_real_us # Amazon Kindle Fire HD 8 - api 22 (5.1.1)
47+
# At the time of writing (August, 13, 2025), the market share per android version is:
48+
# 15.0 = 26.75%, 14.0 = 19.5%, 13 = 15.95%
49+
# Using these 3 versions we cover 62.2% of all devices out there. Currently, this is enough for benchmarking scope
6550

6651
artifacts:
6752
download:

.sauce/sentry-uitest-android-ui.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@ espresso:
1818
testApp: ./sentry-android-integration-tests/sentry-uitest-android/build/outputs/apk/androidTest/release/sentry-uitest-android-release-androidTest.apk
1919
suites:
2020

21-
- name: "Android 14 Ui test (api 34)"
21+
- name: "Android 15 Ui test (api 35)"
2222
testOptions:
2323
clearPackageData: true
2424
useTestOrchestrator: true
2525
devices:
2626
- name: ".*"
27-
platformVersion: "14"
27+
platformVersion: "15"
2828

29-
- name: "Android 13 Ui test (api 33)"
29+
- name: "Android 14 Ui test (api 34)"
3030
testOptions:
3131
clearPackageData: true
3232
useTestOrchestrator: true
3333
devices:
3434
- name: ".*"
35-
platformVersion: "13"
35+
platformVersion: "14"
3636

37-
- name: "Android 11 Ui test (api 31)"
37+
- name: "Android 13 Ui test (api 33)"
3838
testOptions:
3939
clearPackageData: true
4040
useTestOrchestrator: true
4141
devices:
4242
- name: ".*"
43-
platformVersion: "11"
43+
platformVersion: "13"
4444

4545
# Controls what artifacts to fetch when the suite on Sauce Cloud has finished.
4646
artifacts:

0 commit comments

Comments
 (0)