diff --git a/agent/fw_hooks.h b/agent/fw_hooks.h index 9d7d54b0e..78b78d63a 100644 --- a/agent/fw_hooks.h +++ b/agent/fw_hooks.h @@ -48,6 +48,7 @@ extern void nr_doctrine2_enable(TSRMLS_D); extern void nr_guzzle3_enable(TSRMLS_D); extern void nr_guzzle4_enable(TSRMLS_D); extern void nr_guzzle6_enable(TSRMLS_D); +extern void nr_guzzle7_enable(TSRMLS_D); extern void nr_laminas_http_enable(TSRMLS_D); extern void nr_mongodb_enable(TSRMLS_D); extern void nr_phpunit_enable(TSRMLS_D); diff --git a/agent/lib_guzzle4.c b/agent/lib_guzzle4.c index 5045e7e70..3334cfb45 100644 --- a/agent/lib_guzzle4.c +++ b/agent/lib_guzzle4.c @@ -445,12 +445,6 @@ NR_PHP_WRAPPER_START(nr_guzzle4_client_construct) { (void)wraprec; NR_UNUSED_SPECIALFN; - /* This is how we distinguish Guzzle 4/5 from other versions. */ - if (0 == nr_guzzle_does_zval_implement_has_emitter(this_var TSRMLS_CC)) { - NR_PHP_WRAPPER_CALL; - goto end; - } - NR_PHP_WRAPPER_CALL; /* @@ -517,7 +511,7 @@ void nr_guzzle4_enable(TSRMLS_D) { * for all requests created on that client. */ nr_php_wrap_user_function(NR_PSTR("GuzzleHttp\\Client::__construct"), - nr_guzzle_client_construct TSRMLS_CC); + nr_guzzle4_client_construct TSRMLS_CC); } void nr_guzzle4_minit(TSRMLS_D) { diff --git a/agent/lib_guzzle6.c b/agent/lib_guzzle6.c index 45cfca5ab..5cb5bd29f 100644 --- a/agent/lib_guzzle6.c +++ b/agent/lib_guzzle6.c @@ -9,14 +9,14 @@ * It is a required component in Drupal 8, and strongly recommended by other * frameworks, including Symfony 2 and 3. * - * Our approach for Guzzle 6 is to register middleware on every client that + * Our approach for Guzzle 6-7 is to register middleware on every client that * adds our headers to the request object, handles responses, and creates * metrics and trace nodes using the internal RequestHandler class declared * below. * * There is one issue with this approach, which is that the middleware is * called when the request is created, rather than when the request is sent. As - * Guzzle 6 removed the event system that allowed us to know exactly when the + * Guzzle 6-7 removed the event system that allowed us to know exactly when the * request was sent, we are unable to get the time of the request being sent * without instrumenting much more deeply into Guzzle's handlers. We consider * this to be an obscure enough edge case that we are not doing this work at @@ -65,12 +65,11 @@ */ #if ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO -/* {{{ newrelic\Guzzle6\RequestHandler class definition and methods */ - /* * True global for the RequestHandler class entry. */ zend_class_entry* nr_guzzle6_requesthandler_ce; +int php_version_compare(char*, char*); /* * Arginfo for the RequestHandler methods. @@ -107,7 +106,7 @@ static void nr_guzzle6_requesthandler_handle_response(zval* handler, zval* response TSRMLS_DC) { nr_segment_t* segment = NULL; - nr_segment_external_params_t external_params = {.library = "Guzzle 6"}; + nr_segment_external_params_t external_params = {.library = "Guzzle 6-7"}; zval* request; zval* method; zval* status; @@ -140,7 +139,7 @@ static void nr_guzzle6_requesthandler_handle_response(zval* handler, if (NRPRG(txn) && NRTXN(special_flags.debug_cat)) { nrl_verbosedebug( - NRL_CAT, "CAT: outbound response: transport='Guzzle 6' %s=" NRP_FMT, + NRL_CAT, "CAT: outbound response: transport='Guzzle 6-7' %s=" NRP_FMT, X_NEWRELIC_APP_DATA, NRP_CAT(external_params.encoded_response_header)); } @@ -206,14 +205,14 @@ static PHP_NAMED_FUNCTION(nr_guzzle6_requesthandler_construct) { zend_update_property(Z_OBJCE_P(this_obj), ZVAL_OR_ZEND_OBJECT(this_obj), NR_PSTR("request"), request TSRMLS_CC); - nr_guzzle_obj_add(this_obj, "Guzzle 6" TSRMLS_CC); + nr_guzzle_obj_add(this_obj, "Guzzle 6-7" TSRMLS_CC); } /* * Proto : void RequestHandler::onFulfilled(Psr\Http\Message\ResponseInterface * $response) * - * Purpose : Called when a Guzzle 6 request promise is fulfilled. + * Purpose : Called when a Guzzle 6-7 request promise is fulfilled. * * Params : 1. The response object. */ @@ -257,7 +256,7 @@ static PHP_NAMED_FUNCTION(nr_guzzle6_requesthandler_onfulfilled) { * Proto : void * RequestHandler::onRejected(GuzzleHttp\Exception\TransferException $e) * - * Purpose : Called when a Guzzle 6 request promise failed. + * Purpose : Called when a Guzzle 6-7 request promise failed. * * Params : 1. The exception object. */ @@ -340,76 +339,22 @@ const zend_function_entry nr_guzzle6_requesthandler_functions[] nr_guzzle6_requesthandler_onrejected_arginfo, ZEND_ACC_PUBLIC) PHP_FE_END}; -/* }}} */ - -NR_PHP_WRAPPER_START(nr_guzzle6_client_construct) { - zval* config; - zend_class_entry* guzzle_client_ce; - zval* handler_stack; - zval* middleware = NULL; - zval* retval; - zval* this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - - (void)wraprec; - NR_UNUSED_SPECIALFN; - - /* This is how we distinguish Guzzle 4/5. */ - if (nr_guzzle_does_zval_implement_has_emitter(this_var TSRMLS_CC)) { - NR_PHP_WRAPPER_CALL; - goto end; - } - - NR_PHP_WRAPPER_CALL; - - /* - * Get our middleware callable (which is just a string), and make sure it's - * actually callable before we invoke push(). (See also PHP-1184.) - */ - middleware = nr_php_zval_alloc(); - nr_php_zval_str(middleware, "newrelic\\Guzzle6\\middleware"); - if (!nr_php_is_zval_valid_callable(middleware TSRMLS_CC)) { - nrl_verbosedebug(NRL_FRAMEWORK, - "%s: middleware string is not considered callable", - __func__); - - nrm_force_add(NRTXN(unscoped_metrics), - "Supportability/library/Guzzle 6/MiddlewareNotCallable", 0); - - goto end; - } - - guzzle_client_ce = nr_php_find_class("guzzlehttp\\client" TSRMLS_CC); - if (NULL == guzzle_client_ce) { - nrl_verbosedebug(NRL_FRAMEWORK, - "%s: unable to get class entry for GuzzleHttp\\Client", - __func__); - goto end; - } - - config = nr_php_get_zval_object_property_with_class( - this_var, guzzle_client_ce, "config" TSRMLS_CC); - if (!nr_php_is_zval_valid_array(config)) { - goto end; - } - - handler_stack = nr_php_zend_hash_find(Z_ARRVAL_P(config), "handler"); - if (!nr_php_object_instanceof_class(handler_stack, - "GuzzleHttp\\HandlerStack" TSRMLS_CC)) { - goto end; +static void nr_guzzle_minit(){ + zend_class_entry ce; + char nr_guzzle_request_handler[] = "newrelic\\Guzzle\\RequestHandler"; + if (0 == NRINI(guzzle_enabled)) { + return; } - - retval = nr_php_call(handler_stack, "push", middleware); - - nr_php_zval_free(&retval); - -end: - nr_php_zval_free(&middleware); - nr_php_scope_release(&this_var); + INIT_CLASS_ENTRY(ce, nr_guzzle_request_handler, + nr_guzzle6_requesthandler_functions); + nr_guzzle6_requesthandler_ce + = nr_php_zend_register_internal_class_ex(&ce, NULL TSRMLS_CC); + zend_declare_property_null(nr_guzzle6_requesthandler_ce, NR_PSTR("request"), + ZEND_ACC_PRIVATE TSRMLS_CC); } -NR_PHP_WRAPPER_END -void nr_guzzle6_enable(TSRMLS_D) { - int retval; +static void nr_guzzle_enable(){ + int _retval; if (0 == NRINI(guzzle_enabled)) { return; @@ -429,20 +374,20 @@ void nr_guzzle6_enable(TSRMLS_D) { * as a standalone file, so we can use a normal namespace declaration to * avoid possible clashes. */ - retval = zend_eval_string( - "namespace newrelic\\Guzzle6;" + _retval = zend_eval_string( + "namespace newrelic\\Guzzle;" "use Psr\\Http\\Message\\RequestInterface;" - "if (!function_exists('newrelic\\Guzzle6\\middleware')) {" + /* + * Start by adding the outbound CAT/DT/Synthetics headers to the request. + */ + "if (!function_exists('newrelic\\Guzzle\\middleware')) {" " function middleware(callable $handler) {" " return function (RequestInterface $request, array $options) use " "($handler) {" - /* - * Start by adding the outbound CAT/DT/Synthetics headers to the request. - */ - " foreach (newrelic_get_request_metadata('Guzzle 6') as $k => $v) {" + " foreach (newrelic_get_request_metadata('Guzzle') as $k => $v) {" " $request = $request->withHeader($k, $v);" " }" @@ -459,43 +404,116 @@ void nr_guzzle6_enable(TSRMLS_D) { " };" " }" "}", - NULL, "newrelic/Guzzle6" TSRMLS_CC); + NULL, "newrelic/Guzzle" TSRMLS_CC); - if (SUCCESS == retval) { + if (SUCCESS == _retval) { nr_php_wrap_user_function(NR_PSTR("GuzzleHttp\\Client::__construct"), - nr_guzzle_client_construct TSRMLS_CC); - } else { + nr_guzzle_client_construct_helper TSRMLS_CC); + }else { nrl_warning(NRL_FRAMEWORK, "%s: error evaluating PHP code; not installing handler", __func__); } } -void nr_guzzle6_minit(TSRMLS_D) { - zend_class_entry ce; +/* + * This function checks if the guzzle middleware is callable and adds the + * middleware (newrelic\Guzzle\middleware) to the GuzzleHttp\Client + * handler stack by invoking push(). If the middleware is not callable, the + * function exits by using the goto jump statement + */ +NR_PHP_WRAPPER_START(nr_guzzle_client_construct_helper){ + zval* this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); + zval* retval; + int guzzle_version = 6; + char *version = nr_guzzle_version(this_var); + if (php_version_compare(version, "7") >= 0){ + guzzle_version = 7; + } + nr_free(version); - if (0 == NRINI(guzzle_enabled)) { - return; + (void)wraprec; + NR_UNUSED_SPECIALFN; + NR_PHP_WRAPPER_CALL; + /* + * Get our middleware callable (which is just a string), and make sure it's + * actually callable before we invoke push(). (See also PHP-1184.) + */ + char *str_middleware = "newrelic\\Guzzle\\middleware"; + zval* middleware = nr_php_zval_alloc(); + nr_php_zval_str(middleware, str_middleware); + + if (!nr_php_is_zval_valid_callable(middleware TSRMLS_CC)) { + nrl_verbosedebug(NRL_FRAMEWORK, + "%s: middleware string is not considered callable", + __func__); + char* error_message = nr_formatf( + "Supportability/library/Guzzle %d/MiddlewareNotCallable", guzzle_version); + nrm_force_add(NRTXN(unscoped_metrics), error_message, 0); + nr_free(error_message); + goto end; } - INIT_CLASS_ENTRY(ce, "newrelic\\Guzzle6\\RequestHandler", - nr_guzzle6_requesthandler_functions); - nr_guzzle6_requesthandler_ce - = nr_php_zend_register_internal_class_ex(&ce, NULL TSRMLS_CC); + zend_class_entry* guzzle_client_ce = nr_php_find_class("guzzlehttp\\client" + TSRMLS_CC); + if (NULL == guzzle_client_ce) { + nrl_verbosedebug(NRL_FRAMEWORK, + "%s: unable to get class entry for GuzzleHttp\\Client", + __func__); + goto end; + } - zend_declare_property_null(nr_guzzle6_requesthandler_ce, NR_PSTR("request"), - ZEND_ACC_PRIVATE TSRMLS_CC); -} + zval* config = nr_php_get_zval_object_property_with_class( + this_var, guzzle_client_ce, "config" TSRMLS_CC); + if (!nr_php_is_zval_valid_array(config)) { + goto end; + } -#else /* PHP < 5.5 */ + zval* handler_stack = nr_php_zend_hash_find(Z_ARRVAL_P(config), "handler"); + if (!nr_php_object_instanceof_class(handler_stack, + "GuzzleHttp\\HandlerStack" TSRMLS_CC)) { + goto end; + } -NR_PHP_WRAPPER_START(nr_guzzle6_client_construct) { - (void)wraprec; - NR_UNUSED_SPECIALFN; - NR_UNUSED_TSRMLS; + retval = nr_php_call(handler_stack, "push", middleware); + + nr_php_zval_free(&retval); + +end: + nr_php_zval_free(&middleware); + nr_php_scope_release(&this_var); } NR_PHP_WRAPPER_END +/* + * Guzzle 7 requires PHP 7.2.0 or later, which is why we will not build Guzzle 7 + * support on older versions and will instead provide simple stubs for the two + * exported functions to avoid linking errors. + */ +#if ZEND_MODULE_API_NO >= ZEND_7_2_X_API_NO + +void nr_guzzle7_enable(TSRMLS_D) { + nr_guzzle_enable(); +} + +#else /* PHP < 7.2 */ + +void nr_guzzle7_enable(TSRMLS_D) { + NR_UNUSED_TSRMLS +} + +#endif /* 7.2.x */ + +void nr_guzzle6_enable(TSRMLS_D) { + nr_guzzle_enable(); +} + +void nr_guzzle6_minit(TSRMLS_D) { + nr_guzzle_minit(); +} + +#else /* PHP < 5.5 */ + void nr_guzzle6_enable(TSRMLS_D) { NR_UNUSED_TSRMLS } @@ -504,4 +522,4 @@ void nr_guzzle6_minit(TSRMLS_D) { NR_UNUSED_TSRMLS; } -#endif /* 5.5.x */ +#endif /* 5.5.x */ \ No newline at end of file diff --git a/agent/lib_guzzle6.h b/agent/lib_guzzle6.h index 67bff7ecf..846ac74b6 100644 --- a/agent/lib_guzzle6.h +++ b/agent/lib_guzzle6.h @@ -12,14 +12,17 @@ #include "php_includes.h" /* - * Purpose : Performs tasks that we need performed on MINIT in the Guzzle 6 + * Purpose : Performs tasks that we need performed on MINIT in the Guzzle 6 and 7 * instrumentation. */ extern void nr_guzzle6_minit(TSRMLS_D); +extern void nr_guzzle7_minit(TSRMLS_D); /* - * Purpose : Client::__construct() wrapper for Guzzle 6. + * Purpose : Client::__construct() wrapper for Guzzle 6 and 7. */ +extern NR_PHP_WRAPPER_PROTOTYPE(nr_guzzle_client_construct_helper); extern NR_PHP_WRAPPER_PROTOTYPE(nr_guzzle6_client_construct); +extern NR_PHP_WRAPPER_PROTOTYPE(nr_guzzle7_client_construct); #endif /* LIB_GUZZLE4_HDR */ diff --git a/agent/lib_guzzle_common.c b/agent/lib_guzzle_common.c index 7121702cc..e16d3c844 100644 --- a/agent/lib_guzzle_common.c +++ b/agent/lib_guzzle_common.c @@ -8,9 +8,15 @@ #include "php_user_instrument.h" #include "php_hash.h" #include "php_wrapper.h" +#include "php_execute.h" +#include "php_globals.h" #include "lib_guzzle_common.h" #include "lib_guzzle4.h" #include "lib_guzzle6.h" +#include "fw_laravel.h" +#include "fw_laravel_queue.h" +#include "fw_support.h" +#include "php_error.h" #include "nr_header.h" #include "util_logging.h" #include "util_memory.h" @@ -74,9 +80,44 @@ int nr_guzzle_in_call_stack(TSRMLS_D) { return in_guzzle; } -int nr_guzzle_does_zval_implement_has_emitter(zval* obj TSRMLS_DC) { - return nr_php_object_instanceof_class( - obj, "GuzzleHttp\\Event\\HasEmitterInterface" TSRMLS_CC); +extern char* nr_guzzle_version(zval* obj TSRMLS_DC) { + char* retval = NULL; + zval* version = NULL; + zend_class_entry* ce = NULL; + + if (0 == nr_php_is_zval_valid_object(obj)) { + nrl_verbosedebug(NRL_FRAMEWORK, "%s: Application object is invalid", + __func__); + return NULL; + } + + ce = Z_OBJCE_P(obj); + if (NULL == ce) { + nrl_verbosedebug(NRL_FRAMEWORK, "%s: Application has NULL class entry", + __func__); + return NULL; + } + + if (nr_php_get_class_constant(ce, "VERSION") == NULL){ + version = nr_php_get_class_constant(ce, "MAJOR_VERSION"); + } else { + version = nr_php_get_class_constant(ce, "VERSION"); + } + if (NULL == version) { + nrl_verbosedebug(NRL_FRAMEWORK, "%s: Application does not have VERSION", + __func__); + return NULL; + } + + if (nr_php_is_zval_valid_string(version)) { + retval = nr_strndup(Z_STRVAL_P(version), Z_STRLEN_P(version)); + } else { + nrl_verbosedebug(NRL_FRAMEWORK, + "%s: expected VERSION be a valid string, got type %d", + __func__, Z_TYPE_P(version)); + } + nr_php_zval_free(&version); + return retval; } nr_segment_t* nr_guzzle_obj_add(const zval* obj, @@ -270,21 +311,3 @@ char* nr_guzzle_response_get_header(const char* header, return value; } - -NR_PHP_WRAPPER_START(nr_guzzle_client_construct) { - int is_guzzle_45 = 0; - zval* this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - - (void)wraprec; - NR_UNUSED_SPECIALFN; - - is_guzzle_45 = nr_guzzle_does_zval_implement_has_emitter(this_var TSRMLS_CC); - nr_php_scope_release(&this_var); - - if (is_guzzle_45) { - NR_PHP_WRAPPER_DELEGATE(nr_guzzle4_client_construct); - } else { - NR_PHP_WRAPPER_DELEGATE(nr_guzzle6_client_construct); - } -} -NR_PHP_WRAPPER_END diff --git a/agent/lib_guzzle_common.h b/agent/lib_guzzle_common.h index 2431945fe..361b40c46 100644 --- a/agent/lib_guzzle_common.h +++ b/agent/lib_guzzle_common.h @@ -31,16 +31,14 @@ extern char* nr_guzzle_create_async_context_name(const char* prefix, extern int nr_guzzle_in_call_stack(TSRMLS_D); /* - * Purpose : Checks if the given object implements - * GuzzleHttp\Event\HasEmitterInterface. For a Client object, this - * indicates that the object is from Guzzle 4 or 5. + * Purpose: This function checks which guzzle version is being used by the object * * Params : 1. The object to check. - * - * Returns : Non-zero if the object does implement the interface; zero - * otherwise. + * + * Returns : A string indicating the guzzle version being used. This string needs + * to be freed by the caller when it is no longer needed. */ -extern int nr_guzzle_does_zval_implement_has_emitter(zval* obj TSRMLS_DC); +extern char* nr_guzzle_version(zval* obj TSRMLS_DC); /* * Purpose : Adds a Guzzle Request object to the hashmap containing all active @@ -97,11 +95,4 @@ extern void nr_guzzle_request_set_outbound_headers(zval* request, extern char* nr_guzzle_response_get_header(const char* header, zval* response TSRMLS_DC); -/* - * Purpose : Wrapper for Client::__construct() that delegates to the correct - * Guzzle 4-5 or Guzzle 6 handler based on which version of Guzzle - * the Client object comes from. - */ -extern NR_PHP_WRAPPER_PROTOTYPE(nr_guzzle_client_construct); - #endif /* LIB_GUZZLE_COMMON_HDR */ diff --git a/agent/php_execute.c b/agent/php_execute.c index c68fcd3b0..530d37cff 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -477,12 +477,13 @@ 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. + * NOTE: The file HasEmitterInterface.php allows us to differentiate + * Guzzle 4-5 from other Guzzle versions */ - {"Guzzle 4-5", "clientinterface.php", nr_guzzle4_enable}, - {"Guzzle 6", "handlerstack.php", nr_guzzle6_enable}, - + {"Guzzle 4-5", "guzzle/src/event/hasemitterinterface.php", + nr_guzzle4_enable}, + {"Guzzle 6", "guzzlehttp/psr7/src/functions.php", nr_guzzle6_enable}, + {"Guzzle 7", "guzzle/src/clienttrait.php", nr_guzzle7_enable}, {"MongoDB", "mongodb/src/client.php", nr_mongodb_enable}, /* diff --git a/agent/php_minit.c b/agent/php_minit.c index c1fac0c96..6f99d8a0a 100644 --- a/agent/php_minit.c +++ b/agent/php_minit.c @@ -36,7 +36,6 @@ #include "util_threads.h" #include "fw_laravel.h" -#include "lib_guzzle4.h" static void php_newrelic_init_globals(zend_newrelic_globals* nrg) { if (nrunlikely(NULL == nrg)) { @@ -640,7 +639,7 @@ PHP_MINIT_FUNCTION(newrelic) { nr_php_set_opcode_handlers(); nrl_debug(NRL_INIT, "MINIT processing done"); -#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO /* PHP 7.4+ */ +#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO /* PHP 8.0+ */ NR_PHP_PROCESS_GLOBALS(zend_offset) = zend_get_resource_handle(dummy); #else NR_PHP_PROCESS_GLOBALS(zend_offset) = zend_get_resource_handle(&dummy); diff --git a/tests/include/guzzle.tar.bz2 b/tests/include/guzzle.tar.bz2 index d62e0b5b6..110e191ab 100644 Binary files a/tests/include/guzzle.tar.bz2 and b/tests/include/guzzle.tar.bz2 differ diff --git a/tests/integration/external/guzzle6/skipif.inc b/tests/integration/external/guzzle6/skipif.inc new file mode 100644 index 000000000..c02bdb52c --- /dev/null +++ b/tests/integration/external/guzzle6/skipif.inc @@ -0,0 +1,15 @@ + 5.5.0 required\n"); +} + +if (!unpack_guzzle(6)) { + die("skip: guzzle 6 installation required\n"); +} diff --git a/tests/integration/external/guzzle6/test_cat.php b/tests/integration/external/guzzle6/test_cat.php index d95b25622..3e1233046 100644 --- a/tests/integration/external/guzzle6/test_cat.php +++ b/tests/integration/external/guzzle6/test_cat.php @@ -10,15 +10,7 @@ /*SKIPIF 5.5.0 required\n"); -} - -if (!unpack_guzzle(6)) { - die("skip: guzzle 6 installation required\n"); -} +require("skipif.inc"); if (!isset($_ENV["ACCOUNT_supportability"]) || !isset($_ENV["APP_supportability"])) { die("skip: env vars required"); @@ -61,8 +53,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]] diff --git a/tests/integration/external/guzzle6/test_dt.php b/tests/integration/external/guzzle6/test_dt.php index 7d2aaec11..3980200de 100644 --- a/tests/integration/external/guzzle6/test_dt.php +++ b/tests/integration/external/guzzle6/test_dt.php @@ -10,15 +10,7 @@ /*SKIPIF 5.5.0 required\n"); -} - -if (!unpack_guzzle(6)) { - die("skip: guzzle 6 installation required\n"); -} +require("skipif.inc"); */ /*INI @@ -50,8 +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]], 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 88cdd6e6c..3ead4410c 100644 --- a/tests/integration/external/guzzle6/test_dt_newrelic_header_disabled.php +++ b/tests/integration/external/guzzle6/test_dt_newrelic_header_disabled.php @@ -10,15 +10,7 @@ /*SKIPIF 5.5.0 required\n"); -} - -if (!unpack_guzzle(6)) { - die("skip: guzzle 6 installation required\n"); -} +require("skipif.inc"); */ /*INI @@ -51,8 +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]], diff --git a/tests/integration/external/guzzle6/test_dt_synthetics.php b/tests/integration/external/guzzle6/test_dt_synthetics.php index 1d100a94e..4ca30f424 100644 --- a/tests/integration/external/guzzle6/test_dt_synthetics.php +++ b/tests/integration/external/guzzle6/test_dt_synthetics.php @@ -10,15 +10,7 @@ /*SKIPIF 5.5.0 required\n"); -} - -if (!unpack_guzzle(6)) { - die("skip: guzzle 6 installation required\n"); -} +require("skipif.inc"); if (!isset($_ENV["SYNTHETICS_HEADER_supportability"])) { die("skip: env vars required"); @@ -73,8 +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]], 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 b15eb28d5..281fd1e38 100644 --- a/tests/integration/external/guzzle6/test_no_cat_no_dt.php +++ b/tests/integration/external/guzzle6/test_no_cat_no_dt.php @@ -10,15 +10,7 @@ /*SKIPIF 5.5.0 required\n"); -} - -if (!unpack_guzzle(6)) { - die("skip: guzzle 6 installation required\n"); -} +require("skipif.inc"); */ /*INI @@ -50,8 +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]] ] ] diff --git a/tests/integration/external/guzzle6/test_spans_are_created_correctly.php b/tests/integration/external/guzzle6/test_spans_are_created_correctly.php index 033151c0e..a24018927 100644 --- a/tests/integration/external/guzzle6/test_spans_are_created_correctly.php +++ b/tests/integration/external/guzzle6/test_spans_are_created_correctly.php @@ -10,15 +10,7 @@ /*SKIPIF 5.5.0 required\n"); -} - -if (!unpack_guzzle(6)) { - die("skip: guzzle 6 installation required\n"); -} +require("skipif.inc"); */ /*INI @@ -85,7 +77,7 @@ "timestamp": "??", "parentId": "??", "span.kind": "client", - "component": "Guzzle 6" + "component": "Guzzle 6-7" }, {}, { diff --git a/tests/integration/external/guzzle7/skipif.inc b/tests/integration/external/guzzle7/skipif.inc new file mode 100644 index 000000000..34ce67f66 --- /dev/null +++ b/tests/integration/external/guzzle7/skipif.inc @@ -0,0 +1,15 @@ + 7.2.0 required\n"); +} + +if (!unpack_guzzle(7)) { + die("skip: guzzle 7 installation required\n"); +} diff --git a/tests/integration/external/guzzle7/test_cat.php b/tests/integration/external/guzzle7/test_cat.php new file mode 100644 index 000000000..4fab78553 --- /dev/null +++ b/tests/integration/external/guzzle7/test_cat.php @@ -0,0 +1,88 @@ + +get($url); +echo $response->getBody(); + +$response = $client->get($url, [ + 'headers' => [ + 'zip' => 'zap']]); +echo $response->getBody(); + +$response = $client->get($url, [ + 'headers' => [ + 'zip' => 'zap', + CUSTOMER_HEADER => 'zap']]); +echo $response->getBody(); \ No newline at end of file diff --git a/tests/integration/external/guzzle7/test_dt.php b/tests/integration/external/guzzle7/test_dt.php new file mode 100644 index 000000000..d536aa862 --- /dev/null +++ b/tests/integration/external/guzzle7/test_dt.php @@ -0,0 +1,85 @@ + +get($url); +echo $response->getBody(); + +$response = $client->get($url, [ + 'headers' => [ + 'zip' => 'zap']]); +echo $response->getBody(); + +$response = $client->get($url, [ + 'headers' => [ + 'zip' => 'zap', + CUSTOMER_HEADER => 'zap']]); +echo $response->getBody(); diff --git a/tests/integration/external/guzzle7/test_dt_newrelic_header_disabled.php b/tests/integration/external/guzzle7/test_dt_newrelic_header_disabled.php new file mode 100644 index 000000000..ab8b19139 --- /dev/null +++ b/tests/integration/external/guzzle7/test_dt_newrelic_header_disabled.php @@ -0,0 +1,84 @@ + +get($url); +echo $response->getBody(); + +$response = $client->get($url, [ + 'headers' => [ + 'zip' => 'zap']]); +echo $response->getBody(); + +$response = $client->get($url, [ + 'headers' => [ + 'zip' => 'zap', + CUSTOMER_HEADER => 'zap']]); +echo $response->getBody(); \ No newline at end of file diff --git a/tests/integration/external/guzzle7/test_dt_synthetics.php b/tests/integration/external/guzzle7/test_dt_synthetics.php new file mode 100644 index 000000000..89e47b58f --- /dev/null +++ b/tests/integration/external/guzzle7/test_dt_synthetics.php @@ -0,0 +1,108 @@ + +get($url); +echo $response->getBody(); + +$response = $client->get($url, [ + 'headers' => [ + 'zip' => 'zap']]); +echo $response->getBody(); + +$response = $client->get($url, [ + 'headers' => [ + 'zip' => 'zap', + CUSTOMER_HEADER => 'zap']]); +echo $response->getBody(); \ No newline at end of file diff --git a/tests/integration/external/guzzle7/test_no_cat_no_dt.php b/tests/integration/external/guzzle7/test_no_cat_no_dt.php new file mode 100644 index 000000000..4cca67f29 --- /dev/null +++ b/tests/integration/external/guzzle7/test_no_cat_no_dt.php @@ -0,0 +1,75 @@ + +get($url); +echo $response->getBody(); + +$response = $client->get($url, [ + 'headers' => [ + 'zip' => 'zap']]); +echo $response->getBody(); + +$response = $client->get($url, [ + 'headers' => [ + 'zip' => 'zap', + CUSTOMER_HEADER => 'zap']]); +echo $response->getBody(); \ No newline at end of file diff --git a/tests/integration/external/guzzle7/test_spans_are_created_correctly.php b/tests/integration/external/guzzle7/test_spans_are_created_correctly.php new file mode 100644 index 000000000..cfb44fcf8 --- /dev/null +++ b/tests/integration/external/guzzle7/test_spans_are_created_correctly.php @@ -0,0 +1,104 @@ +get($url); +echo $response->getBody(); \ No newline at end of file