|
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,40 @@ 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("0", True) |
| 235 | + add_feature_flag("1", True) |
| 236 | + add_feature_flag("2", True) |
| 237 | + add_feature_flag("3", True) |
| 238 | + add_feature_flag("4", True) |
| 239 | + add_feature_flag("5", True) |
| 240 | + add_feature_flag("6", True) |
| 241 | + add_feature_flag("7", True) |
| 242 | + add_feature_flag("8", True) |
| 243 | + add_feature_flag("9", True) |
| 244 | + add_feature_flag("10", True) |
| 245 | + |
| 246 | + (event,) = events |
| 247 | + assert event["spans"][0]["data"] == ApproxDict( |
| 248 | + { |
| 249 | + "flag.evaluation.0": True, |
| 250 | + "flag.evaluation.1": True, |
| 251 | + "flag.evaluation.2": True, |
| 252 | + "flag.evaluation.3": True, |
| 253 | + "flag.evaluation.4": True, |
| 254 | + "flag.evaluation.5": True, |
| 255 | + "flag.evaluation.6": True, |
| 256 | + "flag.evaluation.7": True, |
| 257 | + "flag.evaluation.8": True, |
| 258 | + "flag.evaluation.9": True, |
| 259 | + } |
| 260 | + ) |
| 261 | + assert "flag.evaluation.10" not in event["spans"][0]["data"] |
0 commit comments