@@ -23,7 +23,8 @@ static const unsigned int MAX_TCP_PORT_ALLOWED = UINT16_MAX;
23
23
24
24
static dd_result _pack_command (mpack_writer_t * nonnull w , void * nullable ctx );
25
25
static dd_result _process_response (mpack_node_t root , void * nullable ctx );
26
- static void _process_meta_and_metrics (mpack_node_t root );
26
+ static void _process_meta_and_metrics (
27
+ mpack_node_t root , struct req_info * nonnull ctx );
27
28
static void _pack_agent_details (mpack_writer_t * nonnull w );
28
29
29
30
static const dd_command_spec _spec = {
@@ -78,24 +79,22 @@ static void _pack_agent_details(mpack_writer_t *nonnull w)
78
79
}
79
80
}
80
81
81
- dd_result dd_client_init (dd_conn * nonnull conn )
82
+ dd_result dd_client_init (dd_conn * nonnull conn , struct req_info * nonnull ctx )
82
83
{
83
- return dd_command_exec_cred (conn , & _spec , NULL );
84
+ return dd_command_exec_cred (conn , & _spec , ctx );
84
85
}
85
86
86
87
static dd_result _pack_command (
87
88
mpack_writer_t * nonnull w , ATTR_UNUSED void * nullable ctx )
88
89
{
89
- // unsigned pid, string client_version, runtime_version, rules_file
90
90
mpack_write (w , (uint32_t )getpid ());
91
91
dd_mpack_write_lstr (w , PHP_DDAPPSEC_VERSION );
92
92
dd_mpack_write_lstr (w , PHP_VERSION );
93
93
94
- enabled_configuration configuration = DDAPPSEC_G (enabled_by_configuration );
95
- if (configuration == NOT_CONFIGURED ) {
94
+ if (DDAPPSEC_G (enabled ) == APPSEC_ENABLED_VIA_REMCFG ) {
96
95
mpack_write_nil (w );
97
96
} else {
98
- mpack_write_bool (w , configuration == ENABLED ? true : false );
97
+ mpack_write_bool (w , DDAPPSEC_G ( active ) );
99
98
}
100
99
101
100
// Service details
@@ -206,7 +205,7 @@ static dd_result _process_response(
206
205
mpack_node_t root , ATTR_UNUSED void * nullable ctx )
207
206
{
208
207
// Add any tags and metrics provided by the helper
209
- _process_meta_and_metrics (root );
208
+ _process_meta_and_metrics (root , ctx );
210
209
211
210
// check verdict
212
211
mpack_node_t verdict = mpack_node_array_at (root , 0 );
@@ -246,15 +245,22 @@ static dd_result _process_response(
246
245
return dd_error ;
247
246
}
248
247
249
- static void _process_meta_and_metrics (mpack_node_t root )
248
+ static void _process_meta_and_metrics (mpack_node_t root , struct req_info * nonnull ctx )
250
249
{
250
+ zend_object * span = ctx -> root_span ;
251
+ if (!span ) {
252
+ mlog (
253
+ dd_log_debug , "Meta/metrics in client_init ignored (no root span)" );
254
+ return ;
255
+ }
256
+
251
257
mpack_node_t meta = mpack_node_array_at (root , 3 );
252
258
if (mpack_node_map_count (meta ) > 0 ) {
253
- dd_command_process_meta (meta );
259
+ dd_command_process_meta (meta , span );
254
260
}
255
261
256
262
mpack_node_t metrics = mpack_node_array_at (root , 4 );
257
- dd_command_process_metrics (metrics );
263
+ dd_command_process_metrics (metrics , span );
258
264
}
259
265
260
266
static dd_result _check_helper_version (mpack_node_t root )
0 commit comments