Skip to content

Commit

Permalink
traverse dict for recursive shortening
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelsz-rb committed Apr 16, 2024
1 parent dab08cd commit 764ee1f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rollbar/lib/transforms/shortener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 764ee1f

Please sign in to comment.