Skip to content

Commit 66095e3

Browse files
committed
Merge branch 'main' into feat/profiling-cursor-rules
# Conflicts: # .cursor/rules/overview_dev.mdc
2 parents 7b648b7 + d501a7e commit 66095e3

File tree

285 files changed

+13558
-1691
lines changed

Some content is hidden

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

285 files changed

+13558
-1691
lines changed
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
---
2+
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, changelog, and stacked PRs.
4+
---
5+
6+
# Create Pull Request (sentry-java)
7+
8+
Prepare local changes and create a pull request for the sentry-java repo.
9+
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+
22+
## Step 1: Ensure Feature Branch
23+
24+
```bash
25+
git branch --show-current
26+
```
27+
28+
If on `main` or `master`, create and switch to a new branch:
29+
30+
```bash
31+
git checkout -b <type>/<short-description>
32+
```
33+
34+
Derive the branch name from the changes being made. Use `feat/`, `fix/`, `ref/`, etc. matching the commit type conventions.
35+
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+
38+
## Step 2: Format Code and Regenerate API Files
39+
40+
```bash
41+
./gradlew spotlessApply apiDump
42+
```
43+
44+
This is **required** before every PR in this repo. It formats all Java/Kotlin code via Spotless and regenerates the `.api` binary compatibility files.
45+
46+
If the command fails, diagnose and fix the issue before continuing.
47+
48+
## Step 3: Commit Changes
49+
50+
Check for uncommitted changes:
51+
52+
```bash
53+
git status --porcelain
54+
```
55+
56+
If there are uncommitted changes, invoke the `sentry-skills:commit` skill to stage and commit them following Sentry conventions.
57+
58+
**Important:** When staging, ignore changes that are only relevant for local testing and should not be part of the PR. Common examples:
59+
60+
| Ignore Pattern | Reason |
61+
|---|---|
62+
| Hardcoded booleans flipped for testing | Local debug toggles |
63+
| Sample app config changes (`sentry-samples/`) | Local testing configuration |
64+
| `.env` or credentials files | Secrets |
65+
66+
Restore these files before committing:
67+
68+
```bash
69+
git checkout -- <file-to-restore>
70+
```
71+
72+
## Step 4: Push the Branch
73+
74+
```bash
75+
git push -u origin HEAD
76+
```
77+
78+
If the push fails due to diverged history, ask the user how to proceed rather than force-pushing.
79+
80+
## Step 5: Create PR
81+
82+
Invoke the `sentry-skills:create-pr` skill to create a draft PR. When providing the PR body, use the repo's PR template structure from `.github/pull_request_template.md`:
83+
84+
```
85+
## :scroll: Description
86+
<Describe the changes in detail>
87+
88+
## :bulb: Motivation and Context
89+
<Why is this change required? What problem does it solve?>
90+
91+
## :green_heart: How did you test it?
92+
<Describe how you tested>
93+
94+
## :pencil: Checklist
95+
- [ ] I added GH Issue ID _&_ Linear ID
96+
- [ ] I added tests to verify the changes.
97+
- [ ] No new PII added or SDK only sends newly added PII if `sendDefaultPII` is enabled.
98+
- [ ] I updated the docs if needed.
99+
- [ ] I updated the wizard if needed.
100+
- [ ] Review from the native team if needed.
101+
- [ ] No breaking change or entry added to the changelog.
102+
- [ ] No breaking change for hybrid SDKs or communicated to hybrid SDKs.
103+
104+
## :crystal_ball: Next steps
105+
```
106+
107+
Fill in each section based on the changes being PR'd. Check any checklist items that apply.
108+
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".
122+
123+
## Step 6: Update Changelog
124+
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.
139+
140+
#### Determine the subsection
141+
142+
| Change Type | Subsection |
143+
|---|---|
144+
| New feature | `### Features` |
145+
| Bug fix | `### Fixes` |
146+
| Refactoring, internal cleanup | `### Internal` |
147+
| Dependency update | `### Dependencies` |
148+
149+
Create the subsection under `## Unreleased` if it does not already exist.
150+
151+
#### Entry format
152+
153+
```markdown
154+
- <Short description of the change> ([#<PR_NUMBER>](https://github.com/getsentry/sentry-java/pull/<PR_NUMBER>))
155+
```
156+
157+
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.
158+
159+
#### Commit and push
160+
161+
Stage `CHANGELOG.md`, commit with message `changelog`, and push:
162+
163+
```bash
164+
git add CHANGELOG.md
165+
git commit -m "changelog"
166+
git push
167+
```
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+
```

.craft.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ targets:
4141
maven:io.sentry:sentry-android-fragment:
4242
maven:io.sentry:sentry-bom:
4343
maven:io.sentry:sentry-openfeign:
44-
#maven:io.sentry:sentry-openfeature:
44+
maven:io.sentry:sentry-openfeature:
4545
maven:io.sentry:sentry-opentelemetry-agent:
4646
maven:io.sentry:sentry-opentelemetry-agentcustomization:
4747
maven:io.sentry:sentry-opentelemetry-agentless:
4848
maven:io.sentry:sentry-opentelemetry-agentless-spring:
4949
maven:io.sentry:sentry-opentelemetry-bootstrap:
5050
maven:io.sentry:sentry-opentelemetry-core:
51+
# maven:io.sentry:sentry-opentelemetry-otlp:
52+
# maven:io.sentry:sentry-opentelemetry-otlp-spring:
5153
maven:io.sentry:sentry-apollo:
5254
maven:io.sentry:sentry-jdbc:
5355
maven:io.sentry:sentry-graphql:
@@ -66,3 +68,4 @@ targets:
6668
maven:io.sentry:sentry-reactor:
6769
maven:io.sentry:sentry-ktor-client:
6870
maven:io.sentry:sentry-async-profiler:
71+
maven:io.sentry:sentry-spotlight:

.cursor/rules/api.mdc

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
alwaysApply: false
3+
description: Public API surface, binary compatibility, and common classes to modify
4+
---
5+
# Java SDK Public API
6+
7+
## API Compatibility
8+
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`.
10+
11+
- **Never edit `.api` files manually.** Run `./gradlew apiDump` to regenerate them.
12+
- `./gradlew check` validates current code against `.api` files and fails on unintended changes.
13+
- `@ApiStatus.Internal` marks classes/methods as internal — they still appear in `.api` files but are not part of the public contract.
14+
- `@ApiStatus.Experimental` marks API that may change in future versions.
15+
16+
## Key Public API Classes
17+
18+
### Entry Point
19+
20+
`Sentry` (`sentry` module) is the static entry point. Most public API methods on `Sentry` delegate to `getCurrentScopes()`. When adding a new method to `Sentry`, it typically calls through to `IScopes`.
21+
22+
### Interfaces
23+
24+
| Interface | Description |
25+
|-----------|-------------|
26+
| `IScope` | Single scope — holds data (tags, extras, breadcrumbs, attributes, user, contexts, etc.) |
27+
| `IScopes` | Multi-scope container — manages global, isolation, and current scope; delegates capture calls to `SentryClient` |
28+
| `ISpan` | Performance span — timing, tags, data, measurements |
29+
| `ITransaction` | Top-level transaction — extends `ISpan` |
30+
31+
### Configuration
32+
33+
`SentryOptions` is the base configuration class. Platform-specific subclasses:
34+
- `SentryAndroidOptions` — Android-specific options
35+
- Integration modules may add their own (e.g. `SentrySpringProperties`)
36+
37+
New features must be **opt-in by default** — add a getter/setter pair to the appropriate options class.
38+
39+
### Internal Classes (Not Public API)
40+
41+
| Class | Description |
42+
|-------|-------------|
43+
| `SentryClient` | Sends events/envelopes to Sentry — receives captured data from `Scopes` |
44+
| `SentryEnvelope` / `SentryEnvelopeItem` | Low-level envelope serialization |
45+
| `Scope` | Concrete implementation of `IScope` |
46+
| `Scopes` | Concrete implementation of `IScopes` |
47+
48+
## Adding New Public API
49+
50+
When adding a new method that users can call (e.g. a new scope operation), these classes typically need changes:
51+
52+
### Interfaces and Static API
53+
1. `IScope` — add the method signature
54+
2. `IScopes` — add the method signature (usually delegates to a scope)
55+
3. `Sentry` — add static method that calls `getCurrentScopes()`
56+
57+
### Implementations
58+
4. `Scope` — actual implementation with data storage
59+
5. `Scopes` — delegates to the appropriate scope (global, isolation, or current based on `defaultScopeType`)
60+
6. `CombinedScopeView` — defines how the three scope types combine for reads (merge, first-wins, or specific scope)
61+
62+
### No-Op and Adapter Classes
63+
7. `NoOpScope` — no-op stub for `IScope`
64+
8. `NoOpScopes` — no-op stub for `IScopes`
65+
9. `ScopesAdapter` — delegates to `Sentry` static API
66+
10. `HubAdapter` — deprecated bridge from old `IHub` API
67+
11. `HubScopesWrapper` — wraps `IScopes` as `IHub`
68+
69+
### Serialization (if the data is sent to Sentry)
70+
12. Add serialization/deserialization in the relevant data class or create a new one implementing `JsonSerializable` and `JsonDeserializer`
71+
72+
### Tests
73+
13. Write tests for all implementations, especially `Scope`, `Scopes`, `SentryTest`, and any new data classes
74+
14. No-op classes typically don't need separate tests unless they have non-trivial logic
75+
76+
## Protocol / Data Model Classes
77+
78+
Classes in the `io.sentry.protocol` package represent the Sentry event protocol. They implement `JsonSerializable` for serialization and have a companion `Deserializer` class implementing `JsonDeserializer`. When adding new fields to protocol classes, update both serialization and deserialization.
79+
80+
## Namespaced APIs
81+
82+
Newer features are namespaced under `Sentry.<feature>()` rather than added directly to `Sentry`. Each namespaced API has an interface, implementation, and no-op. Examples:
83+
84+
- `Sentry.logger()` → `ILoggerApi` / `LoggerApi` / `NoOpLoggerApi` (structured logging, `io.sentry.logger` package)
85+
- `Sentry.metrics()` → `IMetricsApi` / `MetricsApi` / `NoOpMetricsApi` (metrics)
86+
87+
Options for namespaced features are similarly nested under `SentryOptions`, e.g. `SentryOptions.getMetrics()`, `SentryOptions.getLogs()`.
88+
89+
These APIs may share infrastructure like the type system (`SentryAttributeType.inferFrom()`) — changes to shared components (e.g. attribute types) may require updates across multiple namespaced APIs.

.cursor/rules/opentelemetry.mdc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ The Sentry Java SDK provides comprehensive OpenTelemetry integration through mul
1414
- `sentry-opentelemetry-agentless-spring`: Spring-specific agentless integration
1515
- `sentry-opentelemetry-bootstrap`: Classes that go into the bootstrap classloader when the agent is used. For agentless they are simply used in the applications classloader.
1616
- `sentry-opentelemetry-agentcustomization`: Classes that help wire up Sentry in OpenTelemetry. These land in the agent classloader when the agent is used. For agentless they are simply used in the application classloader.
17+
- `sentry-opentelemetry-otlp`: Classes for using OpenTelemetry to send spans to Sentry using the OTLP endpoint and have Sentry use OpenTelemetry trace and span id.
18+
- `sentry-opentelemetry-otlp-spring`: Spring Boot convenience module that includes `sentry-opentelemetry-otlp` and the OpenTelemetry Spring Boot starter as transitive dependencies.
1719

1820
## Advantages over using Sentry without OpenTelemetry
1921

@@ -86,3 +88,10 @@ After creating the transaction with child spans `SentrySpanExporter` uses Sentry
8688
## Troubleshooting
8789

8890
To debug forking of `Scopes`, we added a reference to `parent` `Scopes` and a `creator` String to store the reason why `Scopes` were created or forked.
91+
92+
# OTLP
93+
When using `sentry-opentelemetry-otlp`, Sentry only loads trace ID and span ID from OpenTelemetry `Context` (via `OpenTelemetryOtlpEventProcessor`). Sentry does not rely on OpenTelemetry `Context` for scope storage and propagation, instead relying on its `DefaultScopesStorage`.
94+
It is common to keep Performance in Sentry SDK disabled since that part is taken over by OpenTelemetry.
95+
The `sentry-opentelemetry-otlp` module is not connected to the other `sentry-opentelemetry-*` modules but instead intended only when the goal is to run OpenTelemetry for creating spans and Sentry for other products like errors, logs, metrics etc.
96+
The `sentry-opentelemetry-otlp-spring` module wraps `sentry-opentelemetry-otlp` and includes the OpenTelemetry Spring Boot starter for easier setup in Spring Boot applications.
97+
The OTLP module does not easily work with the OpenTelemetry agent as it would require customizing the agent.JAR in order to get the propagator loaded.

0 commit comments

Comments
 (0)