From 764ee1f065f5720f4ae8dec0187562f891ae5bb3 Mon Sep 17 00:00:00 2001 From: Pawel Date: Mon, 15 Apr 2024 23:01:49 -0700 Subject: [PATCH] traverse dict for recursive shortening --- rollbar/lib/transforms/shortener.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rollbar/lib/transforms/shortener.py b/rollbar/lib/transforms/shortener.py index f0392912..8685429d 100644 --- a/rollbar/lib/transforms/shortener.py +++ b/rollbar/lib/transforms/shortener.py @@ -77,11 +77,22 @@ def _shorten_other(self, obj): return self._repr.repr(obj) + def traverse_dict(self, d): + max_size = self._get_max_size(d) + d = self._shorten_mapping(d, max_size) + for k, v in d.items(): + if isinstance(v, dict): + self.traverse_dict(v) + else: + d[k] = self._shorten(v) + return d + def _shorten(self, val): max_size = self._get_max_size(val) if isinstance(val, dict): - return self._shorten_mapping(val, max_size) + return self.traverse_dict(val) + if isinstance(val, (string_types, sequence_types)): return self._shorten_sequence(val, max_size)