Skip to content

Commit 89d2937

Browse files
committed
fix(agent): just bail early from headers if DT isn't on
1 parent 10858da commit 89d2937

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

agent/lib_php_amqplib.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ static inline void nr_php_amqplib_insert_dt_headers(zval* amqp_msg) {
251251
return;
252252
}
253253

254+
if (!NRPRG(txn)->options.distributed_tracing_enabled) {
255+
return;
256+
}
257+
254258
amqp_properties_array
255259
= nr_php_get_zval_object_property(amqp_msg, "properties");
256260
if (!nr_php_is_zval_valid_array(amqp_properties_array)) {
@@ -286,9 +290,9 @@ static inline void nr_php_amqplib_insert_dt_headers(zval* amqp_msg) {
286290
* The application_headers are stored in an encoded PhpAmqpLib\Wire\AMQPTable
287291
* object
288292
*/
293+
289294
amqp_headers_table = nr_php_zend_hash_find(Z_ARRVAL_P(amqp_properties_array),
290295
"application_headers");
291-
292296
/*
293297
* If the application_headers AMQPTable object doesn't exist, we'll have to
294298
* create it with an empty array.
@@ -311,7 +315,6 @@ static inline void nr_php_amqplib_insert_dt_headers(zval* amqp_msg) {
311315
"create one. Exit.");
312316
goto end;
313317
}
314-
315318
/*
316319
* Set the valid AMQPTable on the AMQPMessage.
317320
*/
@@ -384,6 +387,7 @@ static inline void nr_php_amqplib_insert_dt_headers(zval* amqp_msg) {
384387
NRSAFESTR(Z_STRVAL(key_zval_zpd)));
385388
}
386389
nr_php_zval_free(&retval_set_table_zvf);
390+
zval_ptr_dtor(&key_zval_zpd);
387391
}
388392
}
389393
}
@@ -394,7 +398,6 @@ static inline void nr_php_amqplib_insert_dt_headers(zval* amqp_msg) {
394398
nr_php_zval_free(&retval_set_property_zvf);
395399
zval_ptr_dtor(&application_headers_zpd);
396400
zval_ptr_dtor(&amqp_table_retval_zpd);
397-
zval_ptr_dtor(&key_zval_zpd);
398401
}
399402

400403
/*
@@ -437,6 +440,10 @@ static inline void nr_php_amqplib_retrieve_dt_headers(zval* amqp_msg) {
437440
return;
438441
}
439442

443+
if (!NRPRG(txn)->options.distributed_tracing_enabled) {
444+
return;
445+
}
446+
440447
amqp_properties_array
441448
= nr_php_get_zval_object_property(amqp_msg, "properties");
442449
if (!nr_php_is_zval_valid_array(amqp_properties_array)) {
@@ -769,7 +776,7 @@ void nr_php_amqplib_enable() {
769776
PHP_PACKAGE_VERSION_UNKNOWN);
770777
}
771778

772-
/* Extract the version for aws-sdk 3+ */
779+
/* Extract the version */
773780
nr_php_amqplib_handle_version();
774781
nr_php_amqplib_ensure_class();
775782

0 commit comments

Comments
 (0)