Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datadog_lambda/tag_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def tag_object(span, key, obj, depth=0):
if obj is None:
return span.set_tag(key, obj)
if depth >= max_depth:
return tag_object(span, key, _redact_val(key, str(obj)[0:5000]))
return span.set_tag(key, _redact_val(key, str(obj)[0:5000]))
depth += 1
if _should_try_string(obj):
parsed = None
Expand Down
27 changes: 27 additions & 0 deletions tests/test_tag_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@ def test_tag_object_max_depth(self):
True,
)

def test_tag_object_max_depth_0(self):
payload = {
"hello": "world",
"level1": {
"level2_dict": {"level3": 3},
"level2_list": [None, True, "nice", {"l3": "v3"}],
"level2_bool": True,
"level2_int": 2,
},
"vals": [{"thingOne": 1}, {"thingTwo": 2}],
}
spanMock = MagicMock()
import datadog_lambda.tag_object as lib_ref

lib_ref.max_depth = 0 # setting up the test
tag_object(spanMock, "function.request", payload)
lib_ref.max_depth = 10 # revert the setup
spanMock.set_tag.assert_has_calls(
[
call(
"function.request",
"{'hello': 'world', 'level1': {'level2_dict': {'level3': 3}, 'level2_list': [None, True, 'nice', {'l3': 'v3'}], 'level2_bool': True, 'level2_int': 2}, 'vals': [{'thingOne': 1}, {'thingTwo': 2}]}",
),
],
True,
)

def test_redacted_tag_object(self):
payload = {
"authorization": "world",
Expand Down