Skip to content

Commit 0bd1728

Browse files
authored
feat(agent): Add RabbitMQ instrumentation using the php-amqplib library (#1009)
Most of the PR is basic instrumentation, retrieval of values and setting attributes or creating metrics and is very similar to patterns we've established in other instrumentation. The DT header insertion logic is the trickiest bit since we are modifying the headers in flight. (look to drupal and laravel for similar logic). Note: the DT header insertion logic, while trickiest, is something that can be turned off anytime by the user by setting newrelic.distributed_tracing_exclude_newrelic_header to true. Initial commit does the following: * Detect library via magic file * Detect package and version information. * Basic unit tests Subsequent commits: * Add attributes needed for rabbitMQ to message segment * Instrument basic_publish and basic_get * add unit tests, multiverse tests * added support for PHP 7.x * DT header insertion/retrieval * Added more multiverse tests, especially around the DT functionality
1 parent f3f3e96 commit 0bd1728

19 files changed

+1482
-18
lines changed

agent/Makefile.frag

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ TEST_BINARIES = \
9393
tests/test_internal_instrument \
9494
tests/test_hash \
9595
tests/test_lib_aws_sdk_php \
96+
tests/test_lib_php_amqplib \
9697
tests/test_memcached \
9798
tests/test_mongodb \
9899
tests/test_monolog \

agent/config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ if test "$PHP_NEWRELIC" = "yes"; then
231231
LIBRARIES="lib_aws_sdk_php.c lib_monolog.c lib_doctrine2.c lib_guzzle3.c \
232232
lib_guzzle4.c lib_guzzle6.c lib_guzzle_common.c \
233233
lib_mongodb.c lib_phpunit.c lib_predis.c lib_zend_http.c \
234-
lib_composer.c"
234+
lib_composer.c lib_php_amqplib.c"
235235
PHP_NEW_EXTENSION(newrelic, $FRAMEWORKS $LIBRARIES $NEWRELIC_AGENT, $ext_shared,, $(NEWRELIC_CFLAGS))
236236

237237
PHP_SUBST(NEWRELIC_CFLAGS)

agent/fw_hooks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ extern void nr_guzzle4_enable(TSRMLS_D);
4646
extern void nr_guzzle6_enable(TSRMLS_D);
4747
extern void nr_laminas_http_enable(TSRMLS_D);
4848
extern void nr_mongodb_enable(TSRMLS_D);
49+
extern void nr_php_amqplib_enable();
4950
extern void nr_phpunit_enable(TSRMLS_D);
5051
extern void nr_predis_enable(TSRMLS_D);
5152
extern void nr_zend_http_enable(TSRMLS_D);

agent/lib_aws_sdk_php.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,12 @@ void nr_lib_aws_sdk_php_handle_version() {
429429
zval retval;
430430
int result = FAILURE;
431431

432+
/*
433+
* The following block initializes nr_aws_sdk_version to the empty string.
434+
* If it is able to extract the version, nr_aws_sdk_version is set to that.
435+
* Nothing is needed in the catch block.
436+
* The final return will either return a proper version or an empty string.
437+
*/
432438
result = zend_eval_string(
433439
"(function() {"
434440
" $nr_aws_sdk_version = '';"

0 commit comments

Comments
 (0)