Skip to content

Commit 19a0475

Browse files
committed
Set flags in a capped object
1 parent 7944811 commit 19a0475

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

sentry_sdk/feature_flags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ def add_feature_flag(flag, result):
6969

7070
span = sentry_sdk.get_current_span()
7171
if span:
72-
span.set_data(f"flag.evaluation.{flag}", result)
72+
span.set_flag(f"flag.evaluation.{flag}", result)

sentry_sdk/tracing.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ class Span:
278278
"scope",
279279
"origin",
280280
"name",
281+
"_flags",
282+
"_flags_capacity",
281283
)
282284

283285
def __init__(
@@ -313,6 +315,8 @@ def __init__(
313315
self._tags = {} # type: MutableMapping[str, str]
314316
self._data = {} # type: Dict[str, Any]
315317
self._containing_transaction = containing_transaction
318+
self._flags = {} # type: Dict[str, bool]
319+
self._flags_capacity = 0
316320

317321
if hub is not None:
318322
warnings.warn(
@@ -604,6 +608,11 @@ def set_data(self, key, value):
604608
# type: (str, Any) -> None
605609
self._data[key] = value
606610

611+
def set_flag(self, flag, result):
612+
# type: (str, bool) -> None
613+
if len(self._flags) >= self._flags_capacity:
614+
self._flags[flag] = result
615+
607616
def set_status(self, value):
608617
# type: (str) -> None
609618
self.status = value
@@ -707,7 +716,9 @@ def to_json(self):
707716
if tags:
708717
rv["tags"] = tags
709718

710-
data = self._data
719+
data = {}
720+
data.update(self._flags)
721+
data.update(self._data)
711722
if data:
712723
rv["data"] = data
713724

0 commit comments

Comments
 (0)