fix(profiling): Update Profiler.start() call to match the new dd-trace-py API by joeyzhao2018 · Pull Request #733 · DataDog/datadog-lambda-python
What does this PR do?
Update Profiler.start() call in wrapper.py to remove the stop_on_exit and profile_children keyword arguments
that were removed from dd-trace-py's API.
Motivation
dd-trace-py commit 14ebe215 (refactor: native fork-safe threads (#14163), merged Feb 13 2026) removed the
stop_on_exit and profile_children parameters from Profiler.start(). The method now takes no arguments — it
always registers an atexit handler and handles child process profiling via native pthread_atfork.
datadog-lambda-python was still calling self.prof.start(stop_on_exit=False, profile_children=True), which
raises TypeError: Profiler.start() got an unexpected keyword argument 'stop_on_exit' when used with ddtrace>= 4.4.0.
The old arguments are no longer needed:
- stop_on_exit=False — the new implementation always registers an atexit handler, which is harmless in Lambda
since the process lifecycle is managed by the runtime. - profile_children=True — fork handling is now built into the profiler natively via pthread_atfork and uWSGI
postfork hooks.
Backward compatibility: Calling start() with no arguments is compatible with all supported ddtrace versions
(>=3.19.1 for Python 3.8-3.9, >=4.1.1 for Python 3.10+) since both parameters always had default values. The
only behavioral difference on older ddtrace is that stop_on_exit now takes its default of True instead of
False, meaning the profiler registers an atexit handler that flushes the final profile on exit. Since the
wrapper never explicitly calls prof.stop(), this is actually an improvement — profiles that would have been
silently lost are now flushed.
Testing Guidelines
- Build layer with latest dd-trace-py and verify profiler starts without error
- Verify profiling data is submitted from a Lambda invocation
- Confirm no regression with older ddtrace versions (the no-arg start() has always worked since the
parameters had defaults)