Skip to content

Commit cda73e8

Browse files
committed
fix(tracer): remove debug logs
Signed-off-by: Alexandre Rulleau <alexandre.rulleau@datadoghq.com>
1 parent 37ec8f2 commit cda73e8

9 files changed

Lines changed: 212 additions & 179 deletions

File tree

components-rs/common.h

Lines changed: 151 additions & 129 deletions
Large diffs are not rendered by default.

components-rs/crashtracker.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ void ddog_crasht_CrashInfoBuilder_drop(struct ddog_crasht_Handle_CrashInfoBuilde
451451
* which has not previously been dropped.
452452
*/
453453
DDOG_CHECK_RETURN
454-
struct ddog_crasht_CrashInfo_NewResult ddog_crasht_CrashInfoBuilder_build(struct ddog_crasht_Handle_CrashInfoBuilder *builder);
454+
ddog_crasht_CrashInfo_NewResult ddog_crasht_CrashInfoBuilder_build(struct ddog_crasht_Handle_CrashInfoBuilder *builder);
455455

456456
/**
457457
* # Safety
@@ -854,7 +854,7 @@ struct ddog_StringWrapperResult ddog_crasht_demangle(ddog_CharSlice name,
854854
* signal handler is dangerous, so we fork a sidecar to do the stuff we aren't
855855
* allowed to do in the handler.
856856
*
857-
* See comments in [datadog-crashtracker/lib.rs] for a full architecture description.
857+
* See comments in [libdd-crashtracker/lib.rs] for a full architecture description.
858858
* # Safety
859859
* No safety concerns
860860
*/
@@ -868,7 +868,7 @@ DDOG_CHECK_RETURN struct ddog_VoidResult ddog_crasht_receiver_entry_point_stdin(
868868
* signal handler is dangerous, so we fork a sidecar to do the stuff we aren't
869869
* allowed to do in the handler.
870870
*
871-
* See comments in [datadog-crashtracker/lib.rs] for a full architecture
871+
* See comments in [libdd-crashtracker/lib.rs] for a full architecture
872872
* description.
873873
* # Safety
874874
* No safety concerns

components-rs/ddtrace.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,6 @@ ddog_MaybeError ddog_sidecar_connect_php(struct ddog_SidecarTransport **connecti
116116
void ddtrace_sidecar_reconnect(struct ddog_SidecarTransport **transport,
117117
struct ddog_SidecarTransport *(*factory)(void));
118118

119-
// Thread-based sidecar connection (Unix only)
120-
#if !defined(_WIN32)
121-
ddog_MaybeError ddog_sidecar_connect_master(int32_t pid);
122-
ddog_MaybeError ddog_sidecar_connect_worker(int32_t pid,
123-
struct ddog_SidecarTransport **connection);
124-
ddog_MaybeError ddog_sidecar_shutdown_master_listener(void);
125-
bool ddog_sidecar_is_master_listener_active(int32_t pid);
126-
ddog_MaybeError ddog_sidecar_clear_inherited_listener(void);
127-
#endif
128-
129119
bool ddog_shm_limiter_inc(const struct ddog_MaybeShmLimiter *limiter, uint32_t limit);
130120

131121
bool ddog_exception_hash_limiter_inc(struct ddog_SidecarTransport *connection,

components-rs/sidecar.h

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,40 +95,68 @@ ddog_MaybeError ddog_sidecar_connect(struct ddog_SidecarTransport **connection);
9595
/**
9696
* Start master listener thread for thread-based connections (Unix only).
9797
*
98-
* This spawns a listener thread that accepts worker connections.
98+
* This spawns a listener thread that accepts worker connections. Only one
99+
* master listener can be active per process.
100+
*
101+
* # Arguments
102+
* * `pid` - Process ID that owns this listener
103+
*
104+
* # Returns
105+
* * `MaybeError::None` on success
106+
* * `MaybeError::Some(Error)` on failure
99107
*/
100-
#if !defined(_WIN32)
101108
ddog_MaybeError ddog_sidecar_connect_master(int32_t pid);
102-
#endif
103109

104110
/**
105111
* Connect as worker to master listener thread (Unix only).
112+
*
113+
* Establishes a connection to the master listener for the given PID.
114+
*
115+
* # Arguments
116+
* * `pid` - Process ID of the master process
117+
* * `connection` - Output parameter for the connection
118+
*
119+
* # Returns
120+
* * `MaybeError::None` on success
121+
* * `MaybeError::Some(Error)` on failure
106122
*/
107-
#if !defined(_WIN32)
108-
ddog_MaybeError ddog_sidecar_connect_worker(int32_t pid,
109-
struct ddog_SidecarTransport **connection);
110-
#endif
123+
ddog_MaybeError ddog_sidecar_connect_worker(int32_t pid, struct ddog_SidecarTransport **connection);
111124

112125
/**
113126
* Shutdown the master listener thread (Unix only).
127+
*
128+
* Sends shutdown signal and joins the listener thread. This is blocking.
129+
*
130+
* # Returns
131+
* * `MaybeError::None` on success
132+
* * `MaybeError::Some(Error)` on failure
114133
*/
115-
#if !defined(_WIN32)
116134
ddog_MaybeError ddog_sidecar_shutdown_master_listener(void);
117-
#endif
118135

119136
/**
120137
* Check if master listener is active for the given PID (Unix only).
138+
*
139+
* Used for fork detection.
140+
*
141+
* # Arguments
142+
* * `pid` - Process ID to check
143+
*
144+
* # Returns
145+
* * `true` if listener is active for this PID
146+
* * `false` otherwise
121147
*/
122-
#if !defined(_WIN32)
123148
bool ddog_sidecar_is_master_listener_active(int32_t pid);
124-
#endif
125149

126150
/**
127151
* Clear inherited master listener state in child after fork (Unix only).
152+
*
153+
* Child processes must call this to avoid using the parent's listener.
154+
*
155+
* # Returns
156+
* * `MaybeError::None` on success
157+
* * `MaybeError::Some(Error)` on failure
128158
*/
129-
#if !defined(_WIN32)
130159
ddog_MaybeError ddog_sidecar_clear_inherited_listener(void);
131-
#endif
132160

133161
ddog_MaybeError ddog_sidecar_ping(struct ddog_SidecarTransport **transport);
134162

@@ -156,7 +184,8 @@ ddog_MaybeError ddog_sidecar_telemetry_enqueueConfig(struct ddog_SidecarTranspor
156184
ddog_CharSlice config_key,
157185
ddog_CharSlice config_value,
158186
enum ddog_ConfigurationOrigin origin,
159-
ddog_CharSlice config_id);
187+
ddog_CharSlice config_id,
188+
struct ddog_Option_U64 seq_id);
160189

161190
/**
162191
* Reports a dependency to the telemetry.

components-rs/telemetry.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ ddog_MaybeError ddog_telemetry_builder_with_config(struct ddog_TelemetryWorkerBu
4242
ddog_CharSlice name,
4343
ddog_CharSlice value,
4444
enum ddog_ConfigurationOrigin origin,
45-
ddog_CharSlice config_id);
45+
ddog_CharSlice config_id,
46+
struct ddog_Option_U64 seq_id);
4647

4748
/**
4849
* Builds the telemetry worker and return a handle to it

ext/sidecar.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ ddog_SidecarTransport *ddtrace_sidecar_connect(bool is_fork) {
268268
switch (mode) {
269269
case DD_TRACE_SIDECAR_CONNECTION_MODE_SUBPROCESS:
270270
// Force subprocess only
271-
LOG(DEBUG, "Sidecar connection mode: subprocess (forced)");
272271
transport = ddtrace_sidecar_connect_subprocess();
273272
if (!transport) {
274273
LOG(ERROR, "Subprocess connection failed (mode=subprocess, no fallback)");
@@ -277,7 +276,6 @@ ddog_SidecarTransport *ddtrace_sidecar_connect(bool is_fork) {
277276

278277
case DD_TRACE_SIDECAR_CONNECTION_MODE_THREAD:
279278
// Force thread only
280-
LOG(DEBUG, "Sidecar connection mode: thread (forced)");
281279
transport = ddtrace_sidecar_connect_thread();
282280
if (!transport) {
283281
LOG(ERROR, "Thread connection failed (mode=thread, no fallback)");
@@ -287,23 +285,22 @@ ddog_SidecarTransport *ddtrace_sidecar_connect(bool is_fork) {
287285
case DD_TRACE_SIDECAR_CONNECTION_MODE_AUTO:
288286
default:
289287
// Try subprocess first, fallback to thread if needed
290-
LOG(DEBUG, "Sidecar connection mode: auto (trying subprocess first)");
291288
transport = ddtrace_sidecar_connect_subprocess();
292289

293-
if (transport) {
294-
LOG(DEBUG, "Connected to sidecar via subprocess");
295-
} else if (!ddtrace_endpoint) {
296-
// Don't try fallback if endpoint is invalid - both modes need a valid endpoint
297-
// The "Invalid DD_TRACE_AGENT_URL" error was already logged during endpoint creation
298-
} else {
299-
// Subprocess failed but endpoint is valid - try thread mode fallback
300-
LOG(WARN, "Subprocess connection failed, falling back to thread mode");
301-
transport = ddtrace_sidecar_connect_thread();
302-
303-
if (transport) {
304-
LOG(INFO, "Connected to sidecar via thread (fallback)");
290+
if (!transport) {
291+
if (!ddtrace_endpoint) {
292+
// Don't try fallback if endpoint is invalid - both modes need a valid endpoint
293+
// The "Invalid DD_TRACE_AGENT_URL" error was already logged during endpoint creation
305294
} else {
306-
LOG(ERROR, "Both subprocess and thread connections failed, sidecar unavailable");
295+
// Subprocess failed but endpoint is valid - try thread mode fallback
296+
LOG(WARN, "Subprocess connection failed, falling back to thread mode");
297+
transport = ddtrace_sidecar_connect_thread();
298+
299+
if (transport) {
300+
LOG(INFO, "Connected to sidecar via thread (fallback)");
301+
} else {
302+
LOG(ERROR, "Both subprocess and thread connections failed, sidecar unavailable");
303+
}
307304
}
308305
}
309306
break;

tests/ext/sandbox/die_in_sandbox.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ x();
1717

1818
?>
1919
--EXPECTF--
20-
[ddtrace] [debug] Sidecar connection mode: auto (trying subprocess first)
21-
[ddtrace] [debug] Connected to sidecar via subprocess
2220
[ddtrace] [warning] UnwindExit thrown in ddtrace's closure defined at %s:%d for x(): <exit> in Unknown on line 0
2321
[ddtrace] [span] Encoding span: Span { service: die_in_sandbox.php, name: die_in_sandbox.php, resource: die_in_sandbox.php, type: cli, trace_id: %d, span_id: %d, parent_id: %d, start: %d, duration: %d, error: %d, meta: %s, metrics: %s, meta_struct: %s, span_links: %s, span_events: %s }
2422
[ddtrace] [span] Encoding span: Span { service: die_in_sandbox.php, name: x, resource: x, type: cli, trace_id: %d, span_id: %d, parent_id: %d, start: %d, duration: %d, error: %d, meta: %s, metrics: %s, meta_struct: %s, span_links: %s, span_events: %s }

tests/ext/span_on_close.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ $span->onClose = [
2424

2525
?>
2626
--EXPECTF--
27-
[ddtrace] [debug] Sidecar connection mode: auto (trying subprocess first)
28-
[ddtrace] [debug] Connected to sidecar via subprocess
2927
Second
3028
First
3129
[ddtrace] [span] Encoding span: Span { service: %s, name: root span, resource: root span, type: cli, trace_id: %d, span_id: %d, parent_id: %d, start: %d, duration: %d, error: %d, meta: %s, metrics: %s, meta_struct: %s, span_links: %s, span_events: %s }

tests/ext/startup_logging_json_config.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ dd_dump_startup_logs($logs, [
5252
]);
5353
?>
5454
--EXPECT--
55-
[ddtrace] [debug] Sidecar connection mode: auto (trying subprocess first)
56-
[ddtrace] [debug] Connected to sidecar via subprocess
5755
Sanity check
5856
env: "my-env"
5957
service: "my-service"

0 commit comments

Comments
 (0)