diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py index 85a36109ef..a611355c17 100644 --- a/sentry_sdk/scope.py +++ b/sentry_sdk/scope.py @@ -1379,7 +1379,9 @@ def _apply_contexts_to_event(self, event, hint, options): contexts["trace"] = self.get_trace_context() # Add "flags" context - contexts.setdefault("flags", {}).update({"values": self.flags.get()}) + flags = self.flags.get() + if len(flags) > 0: + contexts.setdefault("flags", {}).update({"values": flags}) def _drop(self, cause, ty): # type: (Any, str) -> Optional[Any]