|
7 | 7 |
|
8 | 8 | import sentry_sdk |
9 | 9 | from sentry_sdk.feature_flags import add_feature_flag, FlagBuffer |
| 10 | +from sentry_sdk import start_span, start_transaction |
| 11 | +from tests.conftest import ApproxDict |
10 | 12 |
|
11 | 13 |
|
12 | 14 | def test_featureflags_integration(sentry_init, capture_events, uninstall_integration): |
@@ -220,3 +222,26 @@ def reader(): |
220 | 222 | # shared resource. When deepcopying we should have exclusive access to the underlying |
221 | 223 | # memory. |
222 | 224 | assert error_occurred is False |
| 225 | + |
| 226 | + |
| 227 | +def test_flag_limit(sentry_init, capture_events): |
| 228 | + sentry_init(traces_sample_rate=1.0) |
| 229 | + |
| 230 | + events = capture_events() |
| 231 | + |
| 232 | + with start_transaction(name="hi"): |
| 233 | + with start_span(op="foo", name="bar"): |
| 234 | + add_feature_flag("first", True) |
| 235 | + add_feature_flag("second", True) |
| 236 | + add_feature_flag("third", True) |
| 237 | + add_feature_flag("fourth", True) |
| 238 | + |
| 239 | + (event,) = events |
| 240 | + assert event["spans"][0]["data"] == ApproxDict( |
| 241 | + { |
| 242 | + "flag.evaluation.first": True, |
| 243 | + "flag.evaluation.second": True, |
| 244 | + "flag.evaluation.third": True, |
| 245 | + } |
| 246 | + ) |
| 247 | + assert "flag.evaluation.fourth" not in event["spans"][0]["data"] |
0 commit comments