Skip to content

Commit 340f48b

Browse files
authored
fix(taskworker) Fix parameter size collection (#92090)
I forgot that celery-beat injects kombu objects into task parameters.
1 parent 82d3edc commit 340f48b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/sentry/celery.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,14 @@ def apply_async(self, *args, **kwargs):
115115
should_sample = random.random() <= settings.CELERY_PICKLE_ERROR_REPORT_SAMPLE_RATE
116116
if should_complain or should_sample:
117117
try:
118-
param_size = json.dumps({"args": args, "kwargs": kwargs})
118+
cleaned_kwargs: dict[str, Any] = {}
119+
for k, v in kwargs.items():
120+
# Remove kombu objects that celery injects
121+
module_name = type(v).__module__
122+
if module_name.startswith("kombu."):
123+
continue
124+
cleaned_kwargs[k] = v
125+
param_size = json.dumps({"args": args, "kwargs": cleaned_kwargs})
119126
metrics.distribution(
120127
"celery.task.parameter_bytes",
121128
len(param_size.encode("utf8")),

0 commit comments

Comments
 (0)