Skip to content

Commit

Permalink
fix(agent): just bail early from headers if DT isn't on
Browse files Browse the repository at this point in the history
  • Loading branch information
zsistla committed Feb 6, 2025
1 parent 10858da commit 89d2937
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions agent/lib_php_amqplib.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ static inline void nr_php_amqplib_insert_dt_headers(zval* amqp_msg) {
return;
}

if (!NRPRG(txn)->options.distributed_tracing_enabled) {
return;
}

amqp_properties_array
= nr_php_get_zval_object_property(amqp_msg, "properties");
if (!nr_php_is_zval_valid_array(amqp_properties_array)) {
Expand Down Expand Up @@ -286,9 +290,9 @@ static inline void nr_php_amqplib_insert_dt_headers(zval* amqp_msg) {
* The application_headers are stored in an encoded PhpAmqpLib\Wire\AMQPTable
* object
*/

amqp_headers_table = nr_php_zend_hash_find(Z_ARRVAL_P(amqp_properties_array),
"application_headers");

/*
* If the application_headers AMQPTable object doesn't exist, we'll have to
* create it with an empty array.
Expand All @@ -311,7 +315,6 @@ static inline void nr_php_amqplib_insert_dt_headers(zval* amqp_msg) {
"create one. Exit.");
goto end;
}

/*
* Set the valid AMQPTable on the AMQPMessage.
*/
Expand Down Expand Up @@ -384,6 +387,7 @@ static inline void nr_php_amqplib_insert_dt_headers(zval* amqp_msg) {
NRSAFESTR(Z_STRVAL(key_zval_zpd)));
}
nr_php_zval_free(&retval_set_table_zvf);
zval_ptr_dtor(&key_zval_zpd);
}
}
}
Expand All @@ -394,7 +398,6 @@ static inline void nr_php_amqplib_insert_dt_headers(zval* amqp_msg) {
nr_php_zval_free(&retval_set_property_zvf);
zval_ptr_dtor(&application_headers_zpd);
zval_ptr_dtor(&amqp_table_retval_zpd);
zval_ptr_dtor(&key_zval_zpd);
}

/*
Expand Down Expand Up @@ -437,6 +440,10 @@ static inline void nr_php_amqplib_retrieve_dt_headers(zval* amqp_msg) {
return;
}

if (!NRPRG(txn)->options.distributed_tracing_enabled) {
return;
}

amqp_properties_array
= nr_php_get_zval_object_property(amqp_msg, "properties");
if (!nr_php_is_zval_valid_array(amqp_properties_array)) {
Expand Down Expand Up @@ -769,7 +776,7 @@ void nr_php_amqplib_enable() {
PHP_PACKAGE_VERSION_UNKNOWN);
}

/* Extract the version for aws-sdk 3+ */
/* Extract the version */
nr_php_amqplib_handle_version();
nr_php_amqplib_ensure_class();

Expand Down

0 comments on commit 89d2937

Please sign in to comment.