Skip to content

Commit d137d4e

Browse files
committed
Merge branch 'feat/cache-tracing-wrappers' into feat/cache-tracing-option
2 parents 8ef6ac5 + 6d6f5eb commit d137d4e

File tree

31 files changed

+863
-419
lines changed

31 files changed

+863
-419
lines changed

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

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
---
22
name: create-java-pr
3-
description: Create a pull request in sentry-java. Use when asked to "create pr", "prepare pr", "prep pr", "open pr", "ready for pr", "prepare for review", "finalize changes". Handles branch creation, code formatting, API dump, committing, pushing, PR creation, and changelog.
3+
description: Create a pull request in sentry-java. Use when asked to "create pr", "prepare pr", "prep pr", "open pr", "ready for pr", "prepare for review", "finalize changes". Handles branch creation, code formatting, API dump, committing, pushing, PR creation, changelog, and stacked PRs.
44
---
55

66
# Create Pull Request (sentry-java)
77

88
Prepare local changes and create a pull request for the sentry-java repo.
99

10+
**Required reading:** Before proceeding, read `.cursor/rules/pr.mdc` for the full PR and stacked PR workflow details. That file is the source of truth for PR conventions, stack comment format, branch naming, and merge strategy.
11+
12+
## Step 0: Determine PR Type
13+
14+
Ask the user (or infer from context) whether this is:
15+
16+
- **Standalone PR** — a regular PR targeting `main`. Follow Steps 1–6 as written.
17+
- **First PR of a new stack** — ask for a topic name (e.g. "Global Attributes"). Create a collection branch from `main`, then branch the first PR off it. The first PR targets the collection branch.
18+
- **Next PR in an existing stack** — identify the previous stack branch and topic. This PR targets the previous stack branch.
19+
20+
If the user mentions "stack", "stacked PR", or provides a topic name with a number (e.g. `[Topic 2]`), treat it as a stacked PR. See `.cursor/rules/pr.mdc` § "Stacked PRs" for full details.
21+
1022
## Step 1: Ensure Feature Branch
1123

1224
```bash
@@ -21,6 +33,8 @@ git checkout -b <type>/<short-description>
2133

2234
Derive the branch name from the changes being made. Use `feat/`, `fix/`, `ref/`, etc. matching the commit type conventions.
2335

36+
**For stacked PRs:** For the first PR in a new stack, first create and push the collection branch (see `.cursor/rules/pr.mdc` § "Creating the Collection Branch"), then branch the PR off it. For subsequent PRs, branch off the previous stack branch. Use the naming conventions from `.cursor/rules/pr.mdc` § "Branch Naming".
37+
2438
## Step 2: Format Code and Regenerate API Files
2539

2640
```bash
@@ -92,13 +106,38 @@ Invoke the `sentry-skills:create-pr` skill to create a draft PR. When providing
92106

93107
Fill in each section based on the changes being PR'd. Check any checklist items that apply.
94108

95-
Then continue to Step 6.
109+
**For stacked PRs:**
110+
111+
- Pass `--base <previous-stack-branch>` so the PR targets the previous branch (first PR in a stack targets the collection branch).
112+
- Use the stacked PR title format: `<type>(<scope>): [<Topic> <N>] <Subject>` (see `.cursor/rules/pr.mdc` § "PR Title Naming").
113+
- Include the stack list at the top of the PR body, before the `## :scroll: Description` section (see `.cursor/rules/pr.mdc` § "Stack List in PR Description" for the format).
114+
115+
Then continue to Step 5.5 (stacked PRs only) or Step 6.
116+
117+
## Step 5.5: Update Stack List on All PRs (stacked PRs only)
118+
119+
Skip this step for standalone PRs.
120+
121+
After creating the PR, update the PR description on **every other PR in the stack** so all PRs have the same up-to-date stack list. Follow the format and commands in `.cursor/rules/pr.mdc` § "Stack List in PR Description".
96122

97123
## Step 6: Update Changelog
98124

99-
After the PR is created, add an entry to `CHANGELOG.md` under the `## Unreleased` section.
125+
First, determine whether a changelog entry is needed. **Skip this step** (and go straight to "No changelog needed" below) if the changes are not user-facing, for example:
126+
127+
- Test-only changes (new tests, test refactors, test fixtures)
128+
- CI/CD or build configuration changes
129+
- Documentation-only changes
130+
- Code comments or formatting-only changes
131+
- Internal refactors with no behavior change visible to SDK users
132+
- Sample app changes
133+
134+
If unsure, ask the user.
135+
136+
### If changelog is needed
137+
138+
Add an entry to `CHANGELOG.md` under the `## Unreleased` section.
100139

101-
### Determine the subsection
140+
#### Determine the subsection
102141

103142
| Change Type | Subsection |
104143
|---|---|
@@ -109,15 +148,15 @@ After the PR is created, add an entry to `CHANGELOG.md` under the `## Unreleased
109148

110149
Create the subsection under `## Unreleased` if it does not already exist.
111150

112-
### Entry format
151+
#### Entry format
113152

114153
```markdown
115154
- <Short description of the change> ([#<PR_NUMBER>](https://github.com/getsentry/sentry-java/pull/<PR_NUMBER>))
116155
```
117156

118157
Use the PR number returned by `sentry-skills:create-pr`. Match the style of existing entries — sentence case, ending with the PR link, no trailing period.
119158

120-
### Commit and push
159+
#### Commit and push
121160

122161
Stage `CHANGELOG.md`, commit with message `changelog`, and push:
123162

@@ -126,3 +165,13 @@ git add CHANGELOG.md
126165
git commit -m "changelog"
127166
git push
128167
```
168+
169+
### No changelog needed
170+
171+
If no changelog entry is needed, add `#skip-changelog` to the PR description to disable the changelog CI check:
172+
173+
```bash
174+
gh pr view <PR_NUMBER> --json body --jq '.body' > /tmp/pr-body.md
175+
printf '\n#skip-changelog\n' >> /tmp/pr-body.md
176+
gh pr edit <PR_NUMBER> --body-file /tmp/pr-body.md
177+
```

.cursor/rules/pr.mdc

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,25 @@ Stacked PRs split a large feature into small, easy-to-review PRs where each buil
120120
### Structure
121121

122122
```
123-
main stack-pr-1 stack-pr-2 stack-pr-3 ...
123+
main ← collection-branch ← stack-pr-1 stack-pr-2 stack-pr-3 ...
124124
```
125125

126-
- The first PR in the stack targets `main` as its base branch.
126+
- A **collection branch** is created from `main` and targets `main`. It serves as the base for the entire stack.
127+
- The first PR in the stack targets the collection branch (not `main`).
127128
- Each subsequent PR targets the previous stack PR's branch as its base.
128129
- Each PR contains only incremental changes on top of the previous one.
129130

131+
The collection branch exists so that individual stack PRs can be **merge-committed** (not squashed). PRs targeting `main` use squash merging, but that causes repeated merge conflicts when syncing the stack. Merge commits on non-`main` branches avoid this. The collection branch itself is squash-merged into `main` at the end.
132+
130133
### Branch Naming
131134

132-
Prefer a shared prefix for the feature, with descriptive suffixes per PR. The type prefix (`feat/`, `fix/`, etc.) may vary depending on the nature of each PR's changes:
135+
Prefer a shared prefix for the feature, with descriptive suffixes per PR. The collection branch uses the shared prefix. The type prefix (`feat/`, `fix/`, etc.) may vary depending on the nature of each PR's changes:
133136

134137
```
135-
feat/scope-attributes # PR 1
136-
feat/scope-attributes-logger # PR 2
137-
fix/attribute-type-detection # PR 3 (fix, different name — that's fine)
138+
feat/scope-attributes # collection branch → targets main
139+
feat/scope-attributes-api # PR 1 → targets collection branch
140+
feat/scope-attributes-logger # PR 2 → targets PR 1
141+
fix/attribute-type-detection # PR 3 (fix, different name — that's fine) → targets PR 2
138142
```
139143

140144
### PR Title Naming
@@ -158,30 +162,42 @@ Do **not** rely on branch name patterns — later PRs in a stack may use differe
158162
```bash
159163
gh pr list --head "$(git branch --show-current)" --json number,title,baseRefName --jq '.[0]'
160164
```
161-
2. Read the stack comment on that PR — it lists every PR in the stack.
162-
3. If there is no stack comment yet, walk the chain in both directions:
165+
2. Read the PR description — the stack list is at the top of the body.
166+
3. If there is no stack list yet, walk the chain in both directions:
163167
```bash
164168
# Find the PR whose head branch is the current PR's base (go up)
165169
gh pr list --head <baseRefName> --json number,title,baseRefName
166170

167171
# Find PRs whose base branch is the current PR's head (go down)
168172
gh pr list --base <currentBranch> --json number,title,headRefName
169173
```
170-
Repeat until you reach `main` going up and find no more PRs going down.
174+
Repeat until you reach the collection branch going up and find no more PRs going down.
175+
176+
### Creating the Collection Branch
177+
178+
Before the first stacked PR, create the collection branch with an empty commit (so GitHub allows opening a PR) and create the collection PR:
179+
180+
```bash
181+
git checkout main
182+
git checkout -b feat/<topic>
183+
git commit --allow-empty -m "collection: <topic>"
184+
git push -u origin HEAD
185+
gh pr create --base main --draft --title "<type>(<scope>): <Topic>" --body "Collection PR for the <Topic> stack. Squash-merge this once all stack PRs are merged."
186+
```
171187

172188
### Creating a New Stacked PR
173189

174-
1. Start from the tip of the previous stack branch (or `main` for the first PR).
190+
1. Start from the tip of the previous stack branch (or the collection branch for the first PR).
175191
2. Create a new branch, make changes, format, commit, and push.
176-
3. Create the PR with `--base <previous-branch>`:
192+
3. Create the PR with `--base <previous-branch>` (the collection branch for the first PR):
177193
```bash
178194
gh pr create --base feat/previous-branch --draft --title "<type>(<scope>): [<Topic> <N>] <Subject>" --body "..."
179195
```
180-
4. Add the stack comment to the new PR and update it on all existing PRs in the stack (see below).
196+
4. Add the stack list to the top of the new PR's description and update it on all existing PRs in the stack (see below).
181197

182-
### Stack Comment
198+
### Stack List in PR Description
183199

184-
Every PR in the stack must have a comment listing all PRs in the stack. When a new PR is added, update the comment on **all** PRs in the stack.
200+
Every PR in the stack must have a stack list **at the top of its description** (before the `## :scroll: Description` section). When a new PR is added, update the description on **all** PRs in the stack.
185201

186202
Format:
187203

@@ -191,26 +207,33 @@ Format:
191207
- [#5118](https://github.com/getsentry/sentry-java/pull/5118) — Add scope-level attributes API
192208
- [#5120](https://github.com/getsentry/sentry-java/pull/5120) — Wire scope attributes into LoggerApi and MetricsApi
193209
- [#5121](https://github.com/getsentry/sentry-java/pull/5121) — Showcase scope attributes in Spring Boot 4 samples
210+
211+
---
194212
```
195213

196-
No status column — GitHub already shows that.
214+
No status column — GitHub already shows that. The `---` separates the stack list from the rest of the PR description.
197215

198-
To add or update the stack comment on a PR:
216+
To update the PR description, use `--body-file` to avoid shell quoting issues with special characters in the body:
199217

200218
```bash
201-
# Find existing stack comment (if any)
202-
gh api repos/getsentry/sentry-java/issues/<PR_NUMBER>/comments --jq '.[] | select(.body | startswith("## PR Stack")) | .id'
219+
# Get current PR description into a temp file
220+
gh pr view <PR_NUMBER> --json body --jq '.body' > /tmp/pr-body.md
203221

204-
# Create new comment
205-
gh pr comment <PR_NUMBER> --body "<stack comment body>"
222+
# Edit /tmp/pr-body.md to prepend or replace the stack list section
223+
# (replace everything from "## PR Stack" up to and including the "---" separator,
224+
# or prepend before the existing description if no stack list exists yet)
206225

207-
# Or update existing comment
208-
gh api repos/getsentry/sentry-java/issues/comments/<COMMENT_ID> -X PATCH -f body="<stack comment body>"
226+
# Update the description
227+
gh pr edit <PR_NUMBER> --body-file /tmp/pr-body.md
209228
```
210229

211-
### Merging Stacked PRs
230+
### Merging Stacked PRs (done by the user, not the agent)
231+
232+
Individual stack PRs are merged in order from bottom to top (PR 1 first, then PR 2, etc.) using **merge commits** (not squash). After each merge, the next PR's base automatically becomes the merged branch's target. GitHub handles rebasing onto the new base.
233+
234+
Once all stack PRs are merged into the collection branch, the collection PR is **squash-merged** into `main`. This gives `main` a clean single commit for the entire feature.
212235

213-
Merge in order from bottom to top (PR 1 first, then PR 2, etc.). After each merge, the next PR's base automatically becomes the merged branch's target. GitHub handles rebasing onto the new base. Verify each PR's diff still looks correct after the previous one merges.
236+
**Do not merge PRs.** Only the user merges PRs.
214237

215238
### Syncing the Stack
216239

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Common: Finalize previous session even when auto session tracking is disabled ([#5154](https://github.com/getsentry/sentry-java/pull/5154))
8+
- Android: Add proguard rules to prevent error about missing Replay classes ([#5153](https://github.com/getsentry/sentry-java/pull/5153))
9+
310
## 8.34.0
411

512
### Features
613

14+
- Allow configuring shutdown and session flush timeouts externally ([#4641](https://github.com/getsentry/sentry-java/pull/4641))
15+
- `sentry.properties`: `shutdown-timeout-millis`, `session-flush-timeout-millis`
16+
- Environment variables: `SENTRY_SHUTDOWN_TIMEOUT_MILLIS`, `SENTRY_SESSION_FLUSH_TIMEOUT_MILLIS`
17+
- Spring Boot `application.properties`: `sentry.shutdownTimeoutMillis`, `sentry.sessionFlushTimeoutMillis`
718
- Add scope-level attributes API ([#5118](https://github.com/getsentry/sentry-java/pull/5118)) via ([#5148](https://github.com/getsentry/sentry-java/pull/5148))
819
- Automatically include scope attributes in logs and metrics ([#5120](https://github.com/getsentry/sentry-java/pull/5120))
920
- New APIs are `Sentry.setAttribute`, `Sentry.setAttributes`, `Sentry.removeAttribute`

sentry-android-core/proguard-rules.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
##---------------Begin: proguard configuration for sentry-android-replay ----------
8181
-dontwarn io.sentry.android.replay.ReplayIntegration
8282
-dontwarn io.sentry.android.replay.DefaultReplayBreadcrumbConverter
83+
-dontwarn io.sentry.android.replay.util.MaskRenderer
84+
-dontwarn io.sentry.android.replay.util.ViewsKt
85+
-dontwarn io.sentry.android.replay.viewhierarchy.ViewHierarchyNode$Companion
86+
-dontwarn io.sentry.android.replay.viewhierarchy.ViewHierarchyNode
8387
-keepnames class io.sentry.android.replay.ReplayIntegration
8488
##---------------End: proguard configuration for sentry-android-replay ----------
8589

sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.sentry.android.core;
22

33
import static io.sentry.Sentry.getCurrentScopes;
4-
import static io.sentry.SentryLevel.DEBUG;
54
import static io.sentry.SentryLevel.INFO;
65
import static io.sentry.SentryLevel.WARNING;
76

@@ -291,13 +290,6 @@ private static void deleteCurrentSessionFile(final @NotNull SentryOptions option
291290
return;
292291
}
293292

294-
if (!options.isEnableAutoSessionTracking()) {
295-
options
296-
.getLogger()
297-
.log(DEBUG, "Session tracking is disabled, bailing from deleting current session file.");
298-
return;
299-
}
300-
301293
final File sessionFile = EnvelopeCache.getCurrentSessionFile(cacheDirPath);
302294
if (!sessionFile.delete()) {
303295
options.getLogger().log(WARNING, "Failed to delete the current session file.");

sentry-android-integration-tests/metrics-test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,3 @@ startupTimeTest:
1010
runs: 50
1111
diffMin: 0
1212
diffMax: 150
13-
14-
binarySizeTest:
15-
diffMin: 600 KiB
16-
diffMax: 850 KiB

sentry-android-integration-tests/sentry-uitest-android/proguard-rules.pro

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,4 @@
4040
-dontwarn org.mockito.internal.**
4141
-dontwarn org.jetbrains.annotations.**
4242
-dontwarn io.sentry.android.replay.ReplayIntegration
43-
-dontwarn io.sentry.android.replay.util.MaskRenderer
44-
-dontwarn io.sentry.android.replay.util.ViewsKt
45-
-dontwarn io.sentry.android.replay.viewhierarchy.ViewHierarchyNode$Companion
46-
-dontwarn io.sentry.android.replay.viewhierarchy.ViewHierarchyNode
4743
-keep class curtains.** { *; }

sentry-jul/src/test/kotlin/io/sentry/jul/SentryHandlerTest.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import io.sentry.SentryLogLevel
77
import io.sentry.SentryOptions
88
import io.sentry.checkEvent
99
import io.sentry.checkLogs
10+
import io.sentry.logger.ILoggerBatchProcessorFactory
11+
import io.sentry.logger.LoggerBatchProcessor
12+
import io.sentry.test.ImmediateExecutorService
13+
import io.sentry.test.applyTestOptions
1014
import io.sentry.test.initForTest
1115
import io.sentry.transport.ITransport
1216
import java.time.Instant
@@ -44,6 +48,10 @@ class SentryHandlerTest {
4448
val options = SentryOptions()
4549
options.dsn = "http://key@localhost/proj"
4650
options.setTransportFactory { _, _ -> transport }
51+
options.logs.loggerBatchProcessorFactory = ILoggerBatchProcessorFactory { options, client ->
52+
LoggerBatchProcessor(options, client, ImmediateExecutorService())
53+
}
54+
applyTestOptions(options)
4755
contextTags?.forEach { options.addContextTag(it) }
4856
logger = Logger.getLogger("jul.SentryHandlerTest")
4957
handler = SentryHandler(options, configureWithLogManager, true)
@@ -415,7 +423,7 @@ class SentryHandlerTest {
415423
fixture = Fixture(minimumLevel = Level.FINEST)
416424
fixture.logger.finest("testing trace level")
417425

418-
Sentry.flush(1000)
426+
Sentry.flush(10)
419427

420428
verify(fixture.transport)
421429
.send(
@@ -431,7 +439,7 @@ class SentryHandlerTest {
431439
fixture = Fixture(minimumLevel = Level.FINE)
432440
fixture.logger.fine("testing trace level")
433441

434-
Sentry.flush(1000)
442+
Sentry.flush(10)
435443

436444
verify(fixture.transport)
437445
.send(checkLogs { event -> assertEquals(SentryLogLevel.DEBUG, event.items.first().level) })
@@ -442,7 +450,7 @@ class SentryHandlerTest {
442450
fixture = Fixture(minimumLevel = Level.CONFIG)
443451
fixture.logger.config("testing debug level")
444452

445-
Sentry.flush(1000)
453+
Sentry.flush(10)
446454

447455
verify(fixture.transport)
448456
.send(checkLogs { event -> assertEquals(SentryLogLevel.DEBUG, event.items.first().level) })
@@ -453,7 +461,7 @@ class SentryHandlerTest {
453461
fixture = Fixture(minimumLevel = Level.INFO)
454462
fixture.logger.info("testing info level")
455463

456-
Sentry.flush(1000)
464+
Sentry.flush(10)
457465

458466
verify(fixture.transport)
459467
.send(checkLogs { event -> assertEquals(SentryLogLevel.INFO, event.items.first().level) })
@@ -464,7 +472,7 @@ class SentryHandlerTest {
464472
fixture = Fixture(minimumLevel = Level.WARNING)
465473
fixture.logger.warning("testing warn level")
466474

467-
Sentry.flush(1000)
475+
Sentry.flush(10)
468476

469477
verify(fixture.transport)
470478
.send(checkLogs { event -> assertEquals(SentryLogLevel.WARN, event.items.first().level) })
@@ -475,7 +483,7 @@ class SentryHandlerTest {
475483
fixture = Fixture(minimumLevel = Level.SEVERE)
476484
fixture.logger.severe("testing error level")
477485

478-
Sentry.flush(1000)
486+
Sentry.flush(10)
479487

480488
verify(fixture.transport)
481489
.send(checkLogs { event -> assertEquals(SentryLogLevel.ERROR, event.items.first().level) })

0 commit comments

Comments
 (0)