Skip to content

Commit 0dd603e

Browse files
docs(profiling): document DD_HEAP_SAMPLING_ENABLED vs native-heap gate
Review asked how ddtrace config and the libdatadog process-start bypass interact; record the two independent AND-gates on the install path.
1 parent 50cbaab commit 0dd603e

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

ddtrace/internal/datadog/profiling/heap_gotter/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
``ddheap:free``) USDT sites fire; the Full Host eBPF profiler attaches uprobes.
1111
Nothing is collected or uploaded from Python.
1212
13+
Two independent runtime gates, both required for GOT to be patched:
14+
15+
* ``DD_PROFILING_NATIVE_HEAP_ENABLED`` — ddtrace install gate (also the
16+
setup.py build gate). When false, this module is not imported from the
17+
profiler and ``install()`` is never called.
18+
* ``DD_HEAP_SAMPLING_ENABLED`` — libdatadog process-start bypass (unset =
19+
on; ``0``/``false``/``no``/``off`` disables). Honored inside
20+
``install_heap_overrides``; a falsey value leaves the GOT untouched and
21+
``install()`` returns False. ddtrace does not set or wrap this variable.
22+
1323
``live_heap_enabled()`` is a compile-time property of the loaded artifact
1424
(default-on ``live-heap`` feature): True when the cdylib stamps retain flags and
1525
emits ``ddheap:free``. False if the cdylib is missing, alloc-only

ddtrace/profiling/profiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ def _start_service(self) -> None:
381381
"""Start the profiler."""
382382
# See DD_PROFILING_NATIVE_HEAP_ENABLED. install() is permanent; children
383383
# inherit the patched GOT (and the activator skips a redundant re-install).
384+
# libdatadog may still refuse the patch via DD_HEAP_SAMPLING_ENABLED
385+
# (unset = on); that is not a ddtrace setting — see heap_gotter docs.
384386
if profiling_config.native_heap.enabled:
385387
from ddtrace.internal.datadog.profiling import heap_gotter
386388

src/native_heap_gotter/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
/// Returns the result of `install_heap_overrides`, i.e. whether at least one
1111
/// allocator symbol's GOT entry was resolved and patched (so hooks will run).
1212
///
13+
/// libdatadog independently honors `DD_HEAP_SAMPLING_ENABLED` (unset =
14+
/// enabled; `0`/`false`/`no`/`off` disables). That check lives inside
15+
/// `install_heap_overrides`: a falsey value returns false without touching
16+
/// the GOT. Distinct from `DD_PROFILING_NATIVE_HEAP_ENABLED`, which is the
17+
/// ddtrace-side gate that decides whether this function is called. This
18+
/// wrapper does not read or set the libdatadog env var.
19+
///
1320
/// After a successful install, a `fork()` child inherits the mapping and the
1421
/// patched GOT, so a second native install is usually unnecessary. Upstream has
1522
/// no `pthread_atfork` child reset for the process-global registry mutex

0 commit comments

Comments
 (0)