Skip to content

Commit ebf77e1

Browse files
committed
Merge branch 'main' into feat/profiling-remove-vendored-code
# Conflicts: # CHANGELOG.md
2 parents 4e6cefe + ce0ff30 commit ebf77e1

File tree

79 files changed

+1569
-3
lines changed

Some content is hidden

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

79 files changed

+1569
-3
lines changed

.craft.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ targets:
6464
maven:io.sentry:sentry-apollo-4:
6565
maven:io.sentry:sentry-reactor:
6666
maven:io.sentry:sentry-ktor-client:
67+
maven:io.sentry:sentry-async-profiler:

.cursor/rules/feature_flags.mdc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
alwaysApply: false
3+
description: Feature Flags
4+
---
5+
# Java SDK Feature Flags
6+
7+
There is a scope based and a span based API for tracking feature flag evaluations.
8+
9+
## Scope Based API
10+
11+
The `addFeatureFlag` method can be used to track feature flag evaluations. It exists on `Sentry` static API as well as `IScopes` and `IScope`.
12+
13+
The `maxFeatureFlags` option controls how many flags are tracked per scope and also how many are sent to Sentry as part of events.
14+
Scope based feature flags can also be disabled by setting the value to 0. Defaults to 100 feature flag evaluations.
15+
16+
Order of feature flag evaluations is important as we only keep track of the last {maxFeatureFlag} items.
17+
18+
When a feature flag evluation with the same name is added, the previous one is removed and the new one is stored so that it'll be dropped last.
19+
20+
When sending out an error event, feature flag buffers from all three scope types (global, isolation and current scope) are merged, chosing the newest {maxFeatureFlag} entries across all scope types. Feature flags are sent as part of the `flags` context.
21+
22+
## Span Based API
23+
24+
tbd

.cursor/rules/overview_dev.mdc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ Use the `fetch_rules` tool to include these rules when working on specific areas
3434
- Rate limiting, cache rotation
3535
- Android vs JVM caching differences
3636

37+
- **`feature_flags`**: Use when working with:
38+
- Feature flag tracking and evaluation
39+
- `addFeatureFlag()`, `getFeatureFlags()` methods
40+
- `FeatureFlagBuffer`, `FeatureFlag` protocol
41+
- `maxFeatureFlags` option and buffer management
42+
- Feature flag merging across scope types
43+
- Scope-based vs span-based feature flag APIs
44+
3745
### Integration & Infrastructure
3846
- **`opentelemetry`**: Use when working with:
3947
- OpenTelemetry modules (`sentry-opentelemetry-*`)
@@ -63,3 +71,4 @@ Use the `fetch_rules` tool to include these rules when working on specific areas
6371
- new module/integration/sample → `new_module`
6472
- Cache/offline/network → `offline`
6573
- System test/e2e/sample → `e2e_tests`
74+
- Feature flag/addFeatureFlag/flag evaluation → `feature_flags`

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
### Features
66

7+
- Add feature flags API ([#4812](https://github.com/getsentry/sentry-java/pull/4812))
8+
- You may now keep track of your feature flag evaluations and have them show up in Sentry.
9+
- You may use top level API (`Sentry.addFeatureFlag("my-feature-flag", true);`) or `IScope` and `IScopes` API
10+
- Feature flag evaluations tracked on scope(s) will be added to any errors reported to Sentry.
11+
- The SDK keeps the latest 100 evaluations from scope(s), replacing old entries as new evaluations are added.
712
- Remove vendored code and upgrade to async profiler 4.2 ([#4856](https://github.com/getsentry/sentry-java/pull/4856))
813
- This adds support for JDK 23+
914

sentry-samples/sentry-samples-console-opentelemetry-noagent/src/main/java/io/sentry/samples/console/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public static void main(String[] args) throws InterruptedException {
6161
// Only data added to the scope on `configureScope` above is included.
6262
Sentry.captureMessage("Some warning!", SentryLevel.WARNING);
6363

64+
Sentry.addFeatureFlag("my-feature-flag", true);
65+
6466
// Sending exception:
6567
Exception exception = new RuntimeException("Some error!");
6668
Sentry.captureException(exception);

sentry-samples/sentry-samples-console-opentelemetry-noagent/src/test/kotlin/sentry/systemtest/ConsoleApplicationSystemTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ConsoleApplicationSystemTest {
5555
// Verify we received the RuntimeException
5656
testHelper.ensureErrorReceived { event ->
5757
event.exceptions?.any { ex -> ex.type == "RuntimeException" && ex.value == "Some error!" } ==
58-
true
58+
true && testHelper.doesEventHaveFlag(event, "my-feature-flag", true)
5959
}
6060

6161
// Verify we received the detailed event with fingerprint

sentry-samples/sentry-samples-console/src/main/java/io/sentry/samples/console/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ public static void main(String[] args) throws InterruptedException {
126126
// Only data added to the scope on `configureScope` above is included.
127127
Sentry.captureMessage("Some warning!", SentryLevel.WARNING);
128128

129+
Sentry.addFeatureFlag("my-feature-flag", true);
130+
129131
// Sending exception:
130132
Exception exception = new RuntimeException("Some error!");
131133
Sentry.captureException(exception);

sentry-samples/sentry-samples-console/src/test/kotlin/io/sentry/systemtest/ConsoleApplicationSystemTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ConsoleApplicationSystemTest {
5151
// Verify we received the RuntimeException
5252
testHelper.ensureErrorReceived { event ->
5353
event.exceptions?.any { ex -> ex.type == "RuntimeException" && ex.value == "Some error!" } ==
54-
true
54+
true && testHelper.doesEventHaveFlag(event, "my-feature-flag", true)
5555
}
5656

5757
// Verify we received the detailed event with fingerprint

sentry-samples/sentry-samples-jul/src/main/java/io/sentry/samples/jul/Main.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sentry.samples.jul;
22

3+
import io.sentry.Sentry;
34
import java.util.UUID;
45
import java.util.logging.Level;
56
import java.util.logging.LogManager;
@@ -22,6 +23,10 @@ public static void main(String[] args) throws Exception {
2223
MDC.put("userId", UUID.randomUUID().toString());
2324
MDC.put("requestId", UUID.randomUUID().toString());
2425

26+
Sentry.addFeatureFlag("my-feature-flag", true);
27+
28+
LOGGER.warning("important warning");
29+
2530
// logging arguments are converted to Sentry Event parameters
2631
LOGGER.log(Level.INFO, "User has made a purchase of product: %d", 445);
2732

sentry-samples/sentry-samples-jul/src/test/kotlin/io/sentry/systemtest/ConsoleApplicationSystemTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ class ConsoleApplicationSystemTest {
5757
} != null
5858
}
5959

60+
testHelper.ensureErrorReceived { event ->
61+
event.message?.message == "important warning" &&
62+
testHelper.doesEventHaveFlag(event, "my-feature-flag", true)
63+
}
64+
6065
testHelper.ensureLogsReceived { logs, _ ->
6166
testHelper.doesContainLogWithBody(logs, "User has made a purchase of product: 445") &&
6267
testHelper.doesContainLogWithBody(logs, "Something went wrong")

0 commit comments

Comments
 (0)