You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .cursor/rules/feature_flags.mdc
+23-3Lines changed: 23 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,35 @@ There is a scope based and a span based API for tracking feature flag evaluation
10
10
11
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
12
13
+
When using static API, `IScopes` or COMBINED scope type, Sentry will also invoke `addFeatureFlag` on the current span. This does not happen, when directly invoking `addFeatureFlag` on `IScope` (except for COMBINED scope type).
14
+
13
15
The `maxFeatureFlags` option controls how many flags are tracked per scope and also how many are sent to Sentry as part of events.
14
16
Scope based feature flags can also be disabled by setting the value to 0. Defaults to 100 feature flag evaluations.
15
17
16
18
Order of feature flag evaluations is important as we only keep track of the last {maxFeatureFlag} items.
17
19
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.
20
+
When a feature flag evaluation with the same name is added, the previous one is removed and the new one is stored so that it'll be dropped last.
21
+
Refer to `FeatureFlagBuffer` fore more details. `FeatureFlagBuffer` has been optimized for storing scope based feature flag evaluations, especially clone performance.
19
22
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.
23
+
When sending out an error event, feature flag buffers from all three scope types (global, isolation and current scope) are merged, choosing the newest {maxFeatureFlag} entries across all scope types. Feature flags are sent as part of the `flags` context.
21
24
22
25
## Span Based API
23
26
24
-
tbd
27
+
It's also possible to use the `addFeatureFlag` method on `ISpan` (and by extension `ITransaction`). Feature flag evaluations tracked this way
28
+
will not be added to the scope and thus won't be added to error events.
29
+
30
+
Each span has its own `SpanFeatureFlagBuffer`. When starting a child span, feature flag evaluations are NOT copied from the parent. Each span starts out with an empty buffer and has its own limit.
31
+
`SpanFeatureFlagBuffer` has been optimized for storing feature flag evaluations on spans.
32
+
33
+
Spans have a hard coded limit of 10 feature flag evaluations. When full, new entries are rejected. Updates to existing entries are still allowed even if full.
34
+
35
+
## Integrations
36
+
37
+
We offer integrations that automatically track feature flag evaluations.
API has been namespaced under `Sentry.metrics()` and `IScopes.metrics()` using the `IMetricsApi` interface and `MetricsApi` implementation.
10
+
11
+
Options are namespaced under `SentryOptions.getMetrics()`.
12
+
13
+
Three different APIs exist:
14
+
- `count`: Counters are one of the more basic types of metrics and can be used to count certain event occurrences.
15
+
- `distribution`: Distributions help you get the most insights from your data by allowing you to obtain aggregations such as p90, min, max, and avg.
16
+
- `gauge`: Gauges let you obtain aggregates like min, max, avg, sum, and count. They can be represented in a more space-efficient way than distributions, but they can't be used to get percentiles. If percentiles aren't important to you, we recommend using gauges.
17
+
18
+
Refer to `SentryMetricsEvent` for details about available fields.
19
+
20
+
`MetricsBatchProcessor` handles batching (`MAX_BATCH_SIZE`), automatic sending of metrics after a timeout (`FLUSH_AFTER_MS`) and rejecting if `MAX_QUEUE_SIZE` has been hit.
21
+
22
+
The flow is `IMetricsApi` -> `IMetricsBatchProcessor` -> `SentryClient.captureBatchedMetricsEvents` -> `ITransport`.
23
+
24
+
Each `SentryMetricsEvent` goes through `SentryOptions.metrics.beforeSend` (if configured) and can be modified or dropped.
25
+
26
+
For sending, a batch of `SentryMetricsEvent` objects is sent inside a `SentryMetricsEvents` object.
0 commit comments