Commit b33ea57
authored
fix: enforce span limit in curl_multi_exec and DDTrace\start_span code paths (#3691)
* fix: enforce span limit in curl_multi_exec and start_span code paths
DD_TRACE_SPANS_LIMIT was correctly enforced in the hook system
(uhook.c, uhook_legacy.c, uhook_attributes.c) but bypassed in three
other code paths, causing unbounded span creation and OOM when
curl_multi_exec is called repeatedly (e.g. AWS SDK SQS workloads).
Missing checks:
- dd_multi_inject_headers() (ext/handlers_curl.c): PHP 8 curl multi
creates one INTERNAL_SPAN per handle without checking the limit.
This is the primary path causing the reported customer OOM.
- dd_inject_distributed_tracing_headers_multi() (ext/handlers_curl_php7.c):
same issue on PHP 7.
- dd_start_span() / DDTrace_start_trace_span() (ext/ddtrace.c):
PHP-level DDTrace\start_span() and DDTrace\start_trace_span() APIs
open real spans without checking the limit.
Fix: add !ddtrace_tracer_is_limited() guards to each path. The curl
multi paths fall through to header injection only (no span) when
limited, preserving distributed tracing propagation. The PHP-level
APIs return a dummy span (matching the disabled-tracing behaviour).
Fixes: APMS-18744
* fix: revert span limit check from user-facing DDTrace\start_span APIs
DDTrace\start_span() and DDTrace\start_trace_span() are user-facing
APIs that intentionally bypass the span limit — the limit applies to
auto-instrumentation (hooks) only. Guarding these APIs with
ddtrace_tracer_is_limited() broke:
- testTracerFlushedWhenSpanLimitExceeded: the test explicitly verifies
that user-created spans work even when DD_TRACE_SPANS_LIMIT is hit.
- Guzzle integration tests: isolateTracer() uses start_trace_span()
internally to create isolated trace contexts; when closed_spans_count
accumulated past the limit across PHPUnit tests, no new stack was
created and all spans in the isolated test were lost.
The curl multi code paths in handlers_curl.c and handlers_curl_php7.c
remain fixed (the actual OOM culprit reported in APMS-18744).1 parent 6bba842 commit b33ea57
2 files changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| |||
0 commit comments