Skip to content

Commit eb5244a

Browse files
committed
Test import of profiler catches error and disables profiling.
1 parent 76dddb9 commit eb5244a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/test_wrapper.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,3 +962,11 @@ def lambda_handler(event, context):
962962
mock_submit.assert_called_once()
963963
call_args = mock_submit.call_args[0]
964964
assert call_args[0] is None
965+
966+
967+
@patch("datadog_lambda.config.Config.profiling_enabled", True)
968+
def test_profiling_import_errors_caught(monkeypatch):
969+
# when importing profiler fails, disable profiling instead of crashing app
970+
monkeypatch.setitem(sys.modules, "ddtrace.profiling", None) # force ModuleNotFoundError
971+
importlib.reload(wrapper)
972+
assert not hasattr(wrapper.datadog_lambda_wrapper, "prof")

0 commit comments

Comments
 (0)