Skip to content

Commit c256355

Browse files
committed
Avoid adding complex Django object to spans
1 parent 36ae7c4 commit c256355

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sentry_sdk/integrations/django/templates.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@ def rendered_content(self):
7373
name=_get_template_name_description(self.template_name),
7474
origin=DjangoIntegration.origin,
7575
) as span:
76-
span.set_data("context", self.context_data)
76+
context_data = {}
77+
for k, v in self.context_data.items():
78+
# Only include primitive types to avoid
79+
# large payloads and long serialization times
80+
if type(v) in (str, int, float, bool, list, dict):
81+
context_data[k] = v
82+
83+
span.set_data("context", context_data)
84+
7785
return real_rendered_content.fget(self)
7886

7987
SimpleTemplateResponse.rendered_content = rendered_content

0 commit comments

Comments
 (0)