Skip to content

Commit 408c89a

Browse files
committed
Merge remote-tracking branch 'origin/main' into danf/monitor-config-utils-mergemain
2 parents d758789 + bdfdc76 commit 408c89a

937 files changed

Lines changed: 36843 additions & 18226 deletions

File tree

Some content is hidden

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

‎.claude/skills/create-java-pr/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Derive the branch name from the changes being made. Use `feat/`, `fix/`, `ref/`,
7474
## Step 2: Format Code and Regenerate API Files
7575

7676
```bash
77-
./gradlew spotlessApply apiDump
77+
./gradlew spotlessApply updateKotlinAbi
7878
```
7979

8080
This is **required** before every PR in this repo. It formats all Java/Kotlin code via Spotless and regenerates the `.api` binary compatibility files.

‎.claude/skills/test/SKILL.md‎

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
---
22
name: test
3-
description: Run tests for a specific SDK module. Use when asked to "run tests", "test module", "run unit tests", "run system tests", "run e2e tests", or test a specific class. Auto-detects unit vs system tests. Supports interactive mode.
3+
description: Run tests for a specific SDK module. Use when asked to "run tests", "test module", "run unit tests", "run integration tests", "run e2e tests", or test a specific class. Auto-detects unit tests vs integration test suites. Supports interactive mode.
44
allowed-tools: Bash, Read, Glob, AskUserQuestion
55
argument-hint: [interactive] <module-name-or-file-path> [test-class-filter]
66
---
77

88
# Run Tests
99

10-
Run tests for a specific module. Auto-detects whether to run unit tests or system tests.
10+
Run tests for a specific module. Auto-detects whether to run unit tests or an integration test
11+
suite.
1112

1213
## Step 0: Check for Interactive Mode
1314

@@ -19,7 +20,7 @@ In interactive mode, use AskUserQuestion at decision points as described in the
1920

2021
The argument can be either:
2122
- A **file path** (e.g., `@sentry/src/test/java/io/sentry/ScopesTest.kt`)
22-
- A **module name** (e.g., `sentry-android-core`, `sentry-samples-spring-boot-4`)
23+
- A **module name** (e.g., `sentry-android-core`, `sentry-spring-boot-4`)
2324
- A **module name + test filter** (e.g., `sentry ScopesTest`)
2425

2526
Extract the module name and optional test class filter from the argument.
@@ -30,10 +31,14 @@ Extract the module name and optional test class filter from the argument.
3031

3132
| Signal | Test Type |
3233
|--------|-----------|
33-
| Path contains `sentry-samples/` | System test |
34-
| Module name starts with `sentry-samples-` | System test |
34+
| Path contains `/src/integrationTest*/` or `/src/agentFixture/` | Integration test suite |
35+
| Module name only, and the user asks for integration or end-to-end tests | Integration test suite: each `src/integrationTest*/` directory of the module |
36+
| Path contains `sentry-samples/`, or module name starts with `sentry-samples-` | None: samples have no tests |
3537
| Everything else | Unit test |
3638

39+
For a sample, tell the user that samples have no tests, and that the end-to-end tests for what
40+
the sample shows live in the module it uses (see the `e2e_tests` rule).
41+
3742
## Step 3a: Run Unit Tests
3843

3944
Determine the Gradle test task:
@@ -60,30 +65,20 @@ Without a filter:
6065
./gradlew ':<module>:<task>' --info
6166
```
6267

63-
## Step 3b: Run System Tests
64-
65-
System tests require the Python-based test runner which manages a mock Sentry server and sample app lifecycle.
66-
67-
1. Ensure the Python venv exists:
68-
```bash
69-
test -d .venv || make setupPython
70-
```
68+
## Step 3b: Run an Integration Test Suite
7169

72-
2. Extract the sample module name. For file paths like `sentry-samples/<sample-module>/src/...`, the sample module is the directory name (e.g., `sentry-samples-spring`).
70+
The suite's task is named after its source set directory: `src/integrationTestWebflux/...` runs
71+
with `integrationTestWebflux`. The OpenTelemetry agent suite runs in two tasks, one per init mode,
72+
so for `src/integrationTestOtelAgent/` or `src/agentFixture/` run both:
7373

74-
3. Run the system test:
7574
```bash
76-
.venv/bin/python test/system-test-runner.py test --module <sample-module>
75+
./gradlew ':<module>:integrationTestOtelAgent' ':<module>:integrationTestOtelAgentWithoutAutoInit'
7776
```
7877

79-
This starts the mock Sentry server, starts the sample app (Spring Boot/Tomcat/CLI), runs tests via `./gradlew :sentry-samples:<sample-module>:systemTest`, and cleans up afterwards.
80-
81-
To run **every** system test instead of one module, use the Makefile targets — they also create the
82-
venv for you:
78+
Otherwise, with or without a test class filter:
8379

8480
```bash
85-
make systemTest # all system tests (--all)
86-
make systemTestInteractive # pick the setups to run (--interactive)
81+
./gradlew ':<module>:<suite>' --tests="*<filter>*"
8782
```
8883

8984
## Step 4: Report Results

‎.craft.yml‎

Lines changed: 237 additions & 0 deletions
Large diffs are not rendered by default.

‎.cursor/BUGBOT.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ rule file in [`.cursor/rules/`](rules) for the area the diff touches (`api`, `op
120120
## What NOT to flag
121121

122122
- Formatting and import order — Spotless owns it.
123-
- Contents of generated `.api` files, beyond confirming `apiDump` was run.
123+
- Contents of generated `.api` files, beyond confirming `updateKotlinAbi` was run.
124124
- Conventional commit / PR title format, and missing changelog entries — CI and Danger check both.
125125
- Speculative refactors or improvements unrelated to the diff.

‎.cursor/rules/api.mdc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ description: Public API surface, binary compatibility, and common classes to mod
66

77
## API Compatibility
88

9-
Public API is tracked via `.api` files generated by the [Binary Compatibility Validator](https://github.com/Kotlin/binary-compatibility-validator) Gradle plugin. Each module has its own file at `<module>/api/<module>.api`.
9+
Public API is tracked via `.api` files generated by the [ABI validation](https://kotlinlang.org/docs/gradle-binary-compatibility-validation.html) built into the Kotlin Gradle plugin. Each module has its own file at `<module>/api/<module>.api`.
1010

11-
- **Never edit `.api` files manually.** Run `./gradlew apiDump` to regenerate them.
11+
- **Never edit `.api` files manually.** Run `./gradlew updateKotlinAbi` to regenerate them.
1212
- `./gradlew check` validates current code against `.api` files and fails on unintended changes.
1313
- `@ApiStatus.Internal` marks classes/methods as internal — they still appear in `.api` files but are not part of the public contract.
1414
- `@ApiStatus.Experimental` marks API that may change in future versions.

‎.cursor/rules/e2e_tests.mdc‎

Lines changed: 79 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,91 @@ alwaysApply: false
33
description: Java SDK End to End Tests
44
---
55

6-
# Java SDK End to End Tests (System Tests)
6+
# Java SDK End to End Tests
77

8-
The samples in the `sentry-samples` directory are used to run end to end tests against them.
8+
End-to-end tests live in the module whose code they test, not in `sentry-samples`. Samples have no
9+
tests. A test runs the code the way an app would and asserts what reaches Sentry over the real HTTP
10+
transport.
911

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.
12+
## MockSentryServer
1113

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.
14+
`MockSentryServer` (`sentry-test-support`) is an in-process HTTP server on a free port. Point the
15+
SDK at `server.dsn`, then:
1316

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.
17+
- `awaitEnvelope(timeoutMillis) { predicate }` polls for a matching envelope and fails with what it
18+
received on timeout.
19+
- `assertNoEnvelope(millis) { predicate }` checks that nothing matching arrives.
20+
- `MockSentryServer { ... }` takes a hook that runs before each check while waiting, for example to
21+
flush an OpenTelemetry tracer provider.
1922

20-
`TestHelper` has a lot of helper methods for asserting, e.g. by span name, log body etc.
23+
`EnvelopeMatchers.kt` has the accessors and matchers: `event()`, `transaction()`, `logs()`,
24+
`metrics()`, `profileChunk()`, `hasSpanWithOp`, `hasFlag`, `hasLogWithAttribute`, `hasMetric` and
25+
so on.
2126

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.
27+
Call `Sentry.flush()` before awaiting when Sentry runs in the test's JVM: logs and metrics are
28+
batched. Envelopes that arrive late can outlive a server's `reset()`, so tests that share a server
29+
match on values only they produce.
2330

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.
31+
## Where the tests are
2532

26-
End to end tests are also executed on CI using a matrix build, as defined in `.github/workflows/system-tests-backend.yml`.
33+
- **Core and plain integrations** use their module's `src/test`. Examples: `SentryEndToEndTest`
34+
(`sentry`), `SentryAppenderIntegrationTest` (`sentry-logback`, `sentry-log4j2`, loading the
35+
appender from XML), `SentryHandlerIntegrationTest` (`sentry-jul`),
36+
`ContinuousProfilerEndToEndTest` (`sentry-async-profiler`), `SentryKafkaEndToEndTest`
37+
(`sentry-kafka`), `AgentlessEndToEndTest` and `OtlpEndToEndTest` (`sentry-opentelemetry-*`).
38+
- **Spring Boot** (`sentry-spring-boot`, `sentry-spring-boot-jakarta`, `sentry-spring-boot-4`) has
39+
one JVM test suite per flavor, because a flavor is a classpath: Sentry's auto-configuration and
40+
OpenTelemetry mode switch on which classes are present.
41+
- `integrationTest`: servlet app.
42+
- `integrationTestWebflux`: reactive app.
43+
- `integrationTestOtelNoAgent`: `sentry-opentelemetry-agentless-spring`.
44+
- `integrationTestOtelAgent` and `integrationTestOtelAgentWithoutAutoInit`: the built agent.
45+
- `integrationTestOtlp` (Boot 4): `sentry-opentelemetry-otlp-spring`.
46+
- `integrationTestLog4j2` (Boot 3, 4): Log4j2 instead of Logback, for the auto-configured
47+
Log4j2 appender.
2748

28-
Some of the samples are tested in multiple ways, e.g. with OpenTelemetry Agent auto init turned on and off.
49+
Each suite has a base class with `@SpringBootTest(RANDOM_PORT)` and a `@DynamicPropertySource`
50+
that sets `sentry.dsn`. Subclasses share one context and one server.
51+
- **Plain Spring** (`sentry-spring`, `sentry-spring-jakarta`, `sentry-spring-7`) has an
52+
`integrationTest` suite that starts the app in an embedded Tomcat, the way a WAR starts. Spring
53+
Boot stays off its classpath, because `SentrySpringServletContainerInitializer` behaves
54+
differently with it.
55+
56+
## The OpenTelemetry agent
57+
58+
The agent must not run in the test's JVM, because it would instrument the test's own HTTP client
59+
and server. The Spring Boot modules have an `agentFixture` source set with the app. `AgentApp`
60+
starts it once per test JVM in a child process, with `ChildJvmApp` and the agent jar passed through
61+
`ChildJvmTestArguments`. The suite's task runs with the agent initializing Sentry, and
62+
`integrationTestOtelAgentWithoutAutoInit` runs the same tests with the Spring Boot starter doing
63+
it. Gradle runs the two in parallel.
64+
65+
## Running them
66+
67+
- The `springBootMatrix` block in each Spring module's build file runs its suites on every version
68+
of its Spring Boot line in `gradle/spring-boot-versions.json`, with a task per suite and version,
69+
e.g. `integrationTestWebfluxBoot3_2_12`. The suites and the SDK compile once, against the
70+
catalog's version; only the runtime classpath changes. `allIntegrationTestsBoot3_2_12` runs one
71+
version's suites, `allIntegrationTestsBoot3` every version's.
72+
- The `spring-boot-{2,3,4}-matrix.yml` workflows read the same file and run each version in its own
73+
job, e.g. `./gradlew :sentry-spring-jakarta:allIntegrationTestsBoot3_2_12
74+
:sentry-spring-boot-jakarta:allIntegrationTestsBoot3_2_12`. The suites aren't part of `check`, so
75+
a new suite only runs on CI once it's added to its module's `springBootMatrix` block, and a new
76+
module once it's added to its workflow.
77+
- Suite code may only use APIs that exist in the oldest version of its line. Compiled against a
78+
newer one, a missing API fails at runtime with `NoSuchMethodError` or `NoClassDefFoundError`.
79+
80+
## Gotchas
81+
82+
- Don't use the context's `TestRestTemplate`. It comes from the `RestTemplateBuilder` that Sentry
83+
customizes, and that the OpenTelemetry starter instruments, so it adds or replaces trace headers
84+
on the requests a test sends. Build one outside the context.
85+
- Sentry exports OpenTelemetry spans in batches every 5 seconds. In-process, flush the tracer
86+
provider from the server's hook. With the agent this isn't possible, so each test waits for a
87+
batch and negative checks wait at least 6 seconds.
88+
- Sentry is global, so a second live Spring context in an OpenTelemetry suite takes it over. Keep
89+
one live context per JVM (`@DirtiesContext` when a test needs its own).
90+
- The async profiler rejects a traces path with a `.` anywhere in its absolute form. Put the path
91+
in `java.io.tmpdir`.
92+
- Kafka uses an in-JVM broker (`@EmbeddedKafka` or spring-kafka-test's broker classes), so no
93+
Docker is needed.

‎.cursor/rules/new_module.mdc‎

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ alwaysApply: false
88

99
This document outlines the complete process for adding a new module to the sentry-java repository. Follow these steps in order to ensure proper integration and release management.
1010

11+
## Publishing Gate
12+
13+
Nothing below is enforced by the build, so a module can look finished, pass CI, and still break
14+
the release that first ships it. All of the following have to be merged **before** that release:
15+
16+
- The module is in the include list in `settings.gradle.kts` (step 1.2)
17+
- Android (AAR) modules are in `Config.BuildScript.androidLibs` (step 1.4)
18+
- The module has a row in the packages table in the main `README.md` (step 3)
19+
- The module is in the integrations dropdown of the matching issue template (step 4)
20+
- The docs page exists on docs.sentry.io (step 5), because `.craft.yml` has to point at a live URL
21+
- The module has a full entry in the `registry` target of `.craft.yml` (step 6) — **this one
22+
fails the release itself**, not just the module
23+
1124
## Step-by-Step Process
1225

1326
### 1. Create the Module Structure
@@ -39,10 +52,12 @@ val SENTRY_FOO_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.foo"
3952
The module's `build.gradle.kts` consumes it in both `buildConfig` and the jar manifest
4053
(`Sentry-SDK-Name` / `Sentry-SDK-Package-Name`) — see `sentry-kafka/build.gradle.kts`.
4154

42-
4. Add the instrumented library to `gradle/libs.versions.toml` and depend on it with
55+
4. For an Android module, add the artifact id to `androidLibs` in `buildSrc/src/main/java/Config.kt`.
56+
57+
5. Add the instrumented library to `gradle/libs.versions.toml` and depend on it with
4358
`compileOnly(libs.<lib>)`, so the integration does not force the dependency on users.
4459

45-
5. Register the integration with the SDK so it is reported in the `sdk` payload. Every
60+
6. Register the integration with the SDK so it is reported in the `sdk` payload. Every
4661
integration does this — see `sentry-openfeature/.../SentryOpenFeatureHook.java`:
4762

4863
```java
@@ -54,24 +69,16 @@ static {
5469
addIntegrationToSdkVersion("{IntegrationName}");
5570
```
5671

57-
6. If adding a JVM sample, add E2E (system) tests, following the structure we have in the existing JVM examples.
58-
The test should then be added to `test/system-test-runner.py` and `.github/workflows/system-tests-backend.yml`.
72+
7. Samples have no tests. Add end-to-end coverage of what the sample shows to the module it uses,
73+
against `MockSentryServer`, as described in the `e2e_tests` rule.
5974

6075
`sentry-bom` and the root `build.gradle.kts` need no change — they iterate over subprojects.
6176

6277
### 2. Create Module Documentation
6378

64-
Create a `README.md` in the module directory with the following structure:
65-
66-
```markdown
67-
# sentry-{module-name}
79+
Create a `README.md` in the module directory: the module name as the heading, what it instruments, and a high level overview.
6880

69-
This module provides an integration for [Technology/Framework Name].
70-
71-
Please consult the documentation on how to install and use this integration in the Sentry Docs for [Android](https://docs.sentry.io/platforms/android/integrations/{module-name}/) or [Java](https://docs.sentry.io/platforms/java/tracing/instrumentation/{module-name}/).
72-
```
73-
74-
The following tasks are required only when adding a module that isn't a sample.
81+
Steps 3 to 6 are required only when adding a module that isn't a sample.
7582

7683
### 3. Update Main README.md
7784

@@ -97,18 +104,9 @@ Add the necessary documentation to [docs.sentry.io](https://docs.sentry.io):
97104
- For Android modules: Add to Android platform docs, usually in integrations section
98105
- Include installation instructions, configuration options, and usage examples
99106

100-
### 6. Post release tasks
101-
102-
Remind the user to perform the following tasks after the module is merged and released:
103-
104-
1. Add the SDK to the Sentry release registry, following the instructions in the [sentry-release-registry README](https://github.com/getsentry/sentry-release-registry#adding-new-sdks)
107+
### 6. Add the Module to `.craft.yml`
105108

106-
2. Add the module to `.craft.yml` in the `sdks` section:
107-
```yaml
108-
sdks:
109-
# ... existing modules ...
110-
maven:io.sentry:sentry-{module-name}:
111-
```
109+
Add the module to the `registry` target in `.craft.yml`, including all metadata fields.
112110

113111
## Module Naming Conventions
114112

‎.cursor/rules/options.mdc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ When a feature has its own capture path (e.g. `captureLog`), the relevant classe
112112
4. `ManifestMetadataReader.java` — Android manifest support (if Android-relevant)
113113
5. `SentryAutoConfigurationTest.kt` — Spring Boot property binding tests (all three Spring Boot modules)
114114
6. Tests for all of the above (`SentryOptionsTest`, `ExternalOptionsTest`, `ManifestMetadataReaderTest`)
115-
7. Run `./gradlew apiDump` — the nested class and its methods appear in `sentry.api`
115+
7. Run `./gradlew updateKotlinAbi` — the nested class and its methods appear in `sentry.api`

‎.envrc‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎.github/CODEOWNERS‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @adinauer @romtsn @markushi @runningcode @0xadam-brown
1+
* @getsentry/team-mobile-android-sdk @adinauer

0 commit comments

Comments
 (0)