Skip to content

Commit b3cc1ac

Browse files
adinauerlciangetsentry-bot
authored
Add AI rules for feature flags (#4819)
* Add scope based feature flags * fix equals * add serialization tests * Create new reference on buffer clone * add comment explaining the merge method * optimize merge method * make flag and result nullable params * handle empty/noop buffer on merge and add tests for it * optimize add method * format; fix test * Add rules for feature flags and mention in overview_dev * Fix duplicate check * Update sentry/src/main/java/io/sentry/SentryOptions.java Co-authored-by: Lorenzo Cian <17258265+lcian@users.noreply.github.com> * Format code * changelog * nullable getFeatureFlags --------- Co-authored-by: Lorenzo Cian <17258265+lcian@users.noreply.github.com> Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
1 parent 5d8a2df commit b3cc1ac

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

.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`

0 commit comments

Comments
 (0)