From 7fd56ae1ebdbebef83d1e80efc267f971d7ec72e Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Fri, 18 Aug 2023 09:56:07 -0400 Subject: [PATCH] refactor(agent): improve guzzle detection (#714) Use files that more uniquely identify Guzzle 5, and Guzzle 6. Because the file used to identify Guzzle 5 is unique to Guzzle 5, Guzzle 4-5 supportability metrics are no longer generated when predis is detected. Guzzle 4-5 supportability metrics is also not generated when Guzzle 6 or Guzzle 7 are detected. --- agent/php_execute.c | 8 ++------ tests/integration/external/guzzle6/test_cat.php | 1 - tests/integration/external/guzzle6/test_dt.php | 1 - .../external/guzzle6/test_dt_newrelic_header_disabled.php | 1 - tests/integration/external/guzzle6/test_dt_synthetics.php | 1 - .../external/guzzle6/test_dt_synthetics_logging_off.php | 1 - tests/integration/external/guzzle6/test_no_cat_no_dt.php | 1 - tests/integration/external/guzzle7/test_cat.php | 1 - tests/integration/external/guzzle7/test_dt.php | 1 - .../external/guzzle7/test_dt_newrelic_header_disabled.php | 1 - tests/integration/external/guzzle7/test_dt_synthetics.php | 1 - tests/integration/external/guzzle7/test_no_cat_no_dt.php | 1 - tests/integration/predis/test_basic.php | 1 - tests/integration/predis/test_basic_logging_off.php | 1 - .../integration/predis/test_basic_reporting_disabled.php | 1 - tests/integration/predis/test_pipeline.php | 1 - tests/integration/predis/test_pipeline_atomic.php | 1 - .../integration/predis/test_pipeline_fire_and_forget.php | 1 - .../predis/test_pipeline_fire_and_forget_logging_off.php | 1 - 19 files changed, 2 insertions(+), 24 deletions(-) diff --git a/agent/php_execute.c b/agent/php_execute.c index 5dee4712d..a6bb53ed5 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -476,12 +476,8 @@ typedef struct _nr_library_table_t { static nr_library_table_t libraries[] = { {"Doctrine 2", "doctrine/orm/query.php", nr_doctrine2_enable}, {"Guzzle 3", "guzzle/http/client.php", nr_guzzle3_enable}, - /* - * NOTE: This file ClientInterface.php also exists in Guzzle 3 and 6. - * This file also exists in Predis. - */ - {"Guzzle 4-5", "clientinterface.php", nr_guzzle4_enable}, - {"Guzzle 6", "handlerstack.php", nr_guzzle6_enable}, + {"Guzzle 4-5", "hasemitterinterface.php", nr_guzzle4_enable}, + {"Guzzle 6", "guzzle/src/functions_include.php", nr_guzzle6_enable}, {"MongoDB", "mongodb/src/client.php", nr_mongodb_enable}, diff --git a/tests/integration/external/guzzle6/test_cat.php b/tests/integration/external/guzzle6/test_cat.php index 62fce17c6..119981b6e 100644 --- a/tests/integration/external/guzzle6/test_cat.php +++ b/tests/integration/external/guzzle6/test_cat.php @@ -51,7 +51,6 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"}, [3, 0, 0, 0, 0, 0]], [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/external/guzzle6/test_dt.php b/tests/integration/external/guzzle6/test_dt.php index c4a366b2c..516611e3e 100644 --- a/tests/integration/external/guzzle6/test_dt.php +++ b/tests/integration/external/guzzle6/test_dt.php @@ -42,7 +42,6 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"}, [3, 0, 0, 0, 0, 0]], [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/external/guzzle6/test_dt_newrelic_header_disabled.php b/tests/integration/external/guzzle6/test_dt_newrelic_header_disabled.php index 86f803062..3f7c5f545 100644 --- a/tests/integration/external/guzzle6/test_dt_newrelic_header_disabled.php +++ b/tests/integration/external/guzzle6/test_dt_newrelic_header_disabled.php @@ -43,7 +43,6 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"}, [3, 0, 0, 0, 0, 0]], [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/external/guzzle6/test_dt_synthetics.php b/tests/integration/external/guzzle6/test_dt_synthetics.php index e7b5f4532..701adc02c 100644 --- a/tests/integration/external/guzzle6/test_dt_synthetics.php +++ b/tests/integration/external/guzzle6/test_dt_synthetics.php @@ -65,7 +65,6 @@ [{"name":"WebTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"WebTransactionTotalTime/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"HttpDispatcher"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"}, [3, 0, 0, 0, 0, 0]], [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/external/guzzle6/test_dt_synthetics_logging_off.php b/tests/integration/external/guzzle6/test_dt_synthetics_logging_off.php index 8d207ec26..64d80aabd 100644 --- a/tests/integration/external/guzzle6/test_dt_synthetics_logging_off.php +++ b/tests/integration/external/guzzle6/test_dt_synthetics_logging_off.php @@ -68,7 +68,6 @@ [{"name":"WebTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"WebTransactionTotalTime/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"HttpDispatcher"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"}, [3, 0, 0, 0, 0, 0]], [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/external/guzzle6/test_no_cat_no_dt.php b/tests/integration/external/guzzle6/test_no_cat_no_dt.php index 31815b8d7..7fceb272b 100644 --- a/tests/integration/external/guzzle6/test_no_cat_no_dt.php +++ b/tests/integration/external/guzzle6/test_no_cat_no_dt.php @@ -42,7 +42,6 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]] diff --git a/tests/integration/external/guzzle7/test_cat.php b/tests/integration/external/guzzle7/test_cat.php index e1abb1499..897ad8ac3 100644 --- a/tests/integration/external/guzzle7/test_cat.php +++ b/tests/integration/external/guzzle7/test_cat.php @@ -53,7 +53,6 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [2, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"}, [3, 0, 0, 0, 0, 0]], diff --git a/tests/integration/external/guzzle7/test_dt.php b/tests/integration/external/guzzle7/test_dt.php index 1bb9bcbff..2f6882b2c 100644 --- a/tests/integration/external/guzzle7/test_dt.php +++ b/tests/integration/external/guzzle7/test_dt.php @@ -42,7 +42,6 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [2, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"}, [3, 0, 0, 0, 0, 0]], [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/external/guzzle7/test_dt_newrelic_header_disabled.php b/tests/integration/external/guzzle7/test_dt_newrelic_header_disabled.php index 4ccd95878..7c7644a0d 100644 --- a/tests/integration/external/guzzle7/test_dt_newrelic_header_disabled.php +++ b/tests/integration/external/guzzle7/test_dt_newrelic_header_disabled.php @@ -43,7 +43,6 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [2, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"}, [3, 0, 0, 0, 0, 0]], diff --git a/tests/integration/external/guzzle7/test_dt_synthetics.php b/tests/integration/external/guzzle7/test_dt_synthetics.php index 50359d92a..33ad546cd 100644 --- a/tests/integration/external/guzzle7/test_dt_synthetics.php +++ b/tests/integration/external/guzzle7/test_dt_synthetics.php @@ -65,7 +65,6 @@ [{"name":"WebTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"WebTransactionTotalTime/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"HttpDispatcher"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [2, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"}, [3, 0, 0, 0, 0, 0]], diff --git a/tests/integration/external/guzzle7/test_no_cat_no_dt.php b/tests/integration/external/guzzle7/test_no_cat_no_dt.php index ecbd9175f..2fb5c830d 100644 --- a/tests/integration/external/guzzle7/test_no_cat_no_dt.php +++ b/tests/integration/external/guzzle7/test_no_cat_no_dt.php @@ -42,7 +42,6 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [2, 0, 0, 0, 0, 0]], [{"name":"Supportability/library/Guzzle 6/detected"}, [1, 0, 0, 0, 0, 0]], [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]] diff --git a/tests/integration/predis/test_basic.php b/tests/integration/predis/test_basic.php index 32864a73b..9c4dcd674 100644 --- a/tests/integration/predis/test_basic.php +++ b/tests/integration/predis/test_basic.php @@ -55,7 +55,6 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/detected"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]] ] diff --git a/tests/integration/predis/test_basic_logging_off.php b/tests/integration/predis/test_basic_logging_off.php index 1dcce308e..1a53a6e43 100644 --- a/tests/integration/predis/test_basic_logging_off.php +++ b/tests/integration/predis/test_basic_logging_off.php @@ -58,7 +58,6 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/detected"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Forwarding/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Metrics/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] ] diff --git a/tests/integration/predis/test_basic_reporting_disabled.php b/tests/integration/predis/test_basic_reporting_disabled.php index 0567f878a..6583c6f1d 100644 --- a/tests/integration/predis/test_basic_reporting_disabled.php +++ b/tests/integration/predis/test_basic_reporting_disabled.php @@ -55,7 +55,6 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/detected"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]] ] diff --git a/tests/integration/predis/test_pipeline.php b/tests/integration/predis/test_pipeline.php index 1a134807f..ef0043038 100644 --- a/tests/integration/predis/test_pipeline.php +++ b/tests/integration/predis/test_pipeline.php @@ -48,7 +48,6 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/detected"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]] ] diff --git a/tests/integration/predis/test_pipeline_atomic.php b/tests/integration/predis/test_pipeline_atomic.php index a266d5c6f..e2aac9dac 100644 --- a/tests/integration/predis/test_pipeline_atomic.php +++ b/tests/integration/predis/test_pipeline_atomic.php @@ -48,7 +48,6 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/detected"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]] ] diff --git a/tests/integration/predis/test_pipeline_fire_and_forget.php b/tests/integration/predis/test_pipeline_fire_and_forget.php index 512fda582..4def76323 100644 --- a/tests/integration/predis/test_pipeline_fire_and_forget.php +++ b/tests/integration/predis/test_pipeline_fire_and_forget.php @@ -48,7 +48,6 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/detected"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]] ] diff --git a/tests/integration/predis/test_pipeline_fire_and_forget_logging_off.php b/tests/integration/predis/test_pipeline_fire_and_forget_logging_off.php index 4be55fd8a..33e4dcdf0 100644 --- a/tests/integration/predis/test_pipeline_fire_and_forget_logging_off.php +++ b/tests/integration/predis/test_pipeline_fire_and_forget_logging_off.php @@ -51,7 +51,6 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/detected"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/library/Guzzle 4-5/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Forwarding/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Metrics/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] ]