Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions agent/fw_cakephp.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,12 @@ void nr_cakephp_enable(TSRMLS_D) {
nr_php_wrap_user_function(
NR_PSTR("Cake\\Controller\\Controller::invokeAction"),
nr_cakephp_name_the_wt_4);
nr_php_wrap_user_function(
NR_PSTR(
"Cake\\Error\\Middleware\\ErrorHandlerMiddleware::handleException"),
nr_cakephp_error_handler_wrapper);
if (!NRINI(ignore_framework_error_exception_handler)) {
nr_php_wrap_user_function(
NR_PSTR(
"Cake\\Error\\Middleware\\ErrorHandlerMiddleware::handleException"),
nr_cakephp_error_handler_wrapper);
}
nr_txn_suggest_package_supportability_metric(NRPRG(txn), PHP_PACKAGE_NAME,
PHP_PACKAGE_VERSION_UNKNOWN);
}
16 changes: 9 additions & 7 deletions agent/fw_drupal8.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,14 +898,16 @@ void nr_drupal8_enable(TSRMLS_D) {
/*
* Log exceptions without further handling.
*/
nr_php_wrap_user_function(NR_PSTR("Drupal\\Core\\EventSubscriber\\ExceptionLoggingSubscriber::onException"),
nr_drupal_exception);
if (!NRINI(ignore_framework_error_exception_handler)) {
nr_php_wrap_user_function(NR_PSTR("Drupal\\Core\\EventSubscriber\\ExceptionLoggingSubscriber::onException"),
nr_drupal_exception);

/*
* Last-chance handler for exceptions: the final exception subscriber.
*/
nr_php_wrap_user_function(NR_PSTR("Drupal\\Core\\EventSubscriber\\FinalExceptionSubscriber::onException"),
nr_drupal_exception);
/*
* Last-chance handler for exceptions: the final exception subscriber.
*/
nr_php_wrap_user_function(NR_PSTR("Drupal\\Core\\EventSubscriber\\FinalExceptionSubscriber::onException"),
nr_drupal_exception);
}
// clang-format on

/*
Expand Down
28 changes: 15 additions & 13 deletions agent/fw_laravel.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,19 +865,21 @@ NR_PHP_WRAPPER(nr_laravel5_application_boot) {
* to sensibly name transactions when an exception is thrown during routing
* and also to record the error.
*/
exception_handler = nr_php_call_offsetGet(
this_var, "Illuminate\\Contracts\\Debug\\ExceptionHandler" TSRMLS_CC);
if (nr_php_is_zval_valid_object(exception_handler)) {
nr_laravel_add_callback_method(Z_OBJCE_P(exception_handler),
NR_PSTR("render"),
nr_laravel5_exception_render TSRMLS_CC);

nr_laravel_add_callback_method(Z_OBJCE_P(exception_handler),
NR_PSTR("report"),
nr_laravel5_exception_report TSRMLS_CC);
} else {
nrl_verbosedebug(NRL_FRAMEWORK, "%s: cannot get exception handler",
__func__);
if (!NRINI(ignore_framework_error_exception_handler)) {
exception_handler = nr_php_call_offsetGet(
this_var, "Illuminate\\Contracts\\Debug\\ExceptionHandler" TSRMLS_CC);
if (nr_php_is_zval_valid_object(exception_handler)) {
nr_laravel_add_callback_method(Z_OBJCE_P(exception_handler),
NR_PSTR("render"),
nr_laravel5_exception_render TSRMLS_CC);

nr_laravel_add_callback_method(Z_OBJCE_P(exception_handler),
NR_PSTR("report"),
nr_laravel5_exception_report TSRMLS_CC);
} else {
nrl_verbosedebug(NRL_FRAMEWORK, "%s: cannot get exception handler",
__func__);
}
}

end:
Expand Down
14 changes: 8 additions & 6 deletions agent/fw_lumen.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,18 @@ void nr_lumen_enable(TSRMLS_D) {
nr_php_wrap_user_function(
NR_PSTR("Laravel\\Lumen\\Application::handleFoundRoute"),
nr_lumen_handle_found_route TSRMLS_CC);
if (!NRINI(ignore_framework_error_exception_handler)) {
#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \
&& !defined OVERWRITE_ZEND_EXECUTE_DATA
nr_php_wrap_user_function_before_after_clean(
NR_PSTR("Laravel\\Lumen\\Application::sendExceptionToHandler"),
nr_lumen_exception, NULL, NULL);
nr_php_wrap_user_function_before_after_clean(
NR_PSTR("Laravel\\Lumen\\Application::sendExceptionToHandler"),
nr_lumen_exception, NULL, NULL);
#else
nr_php_wrap_user_function(
NR_PSTR("Laravel\\Lumen\\Application::sendExceptionToHandler"),
nr_lumen_exception TSRMLS_CC);
nr_php_wrap_user_function(
NR_PSTR("Laravel\\Lumen\\Application::sendExceptionToHandler"),
nr_lumen_exception TSRMLS_CC);
#endif
}

if (NRINI(vulnerability_management_package_detection_enabled)) {
nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME,
Expand Down
26 changes: 14 additions & 12 deletions agent/fw_symfony4.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,21 @@ void nr_symfony4_enable(TSRMLS_D) {
* nr_txn_record_error and pass the exception message. Now we get errors in
* the error analytics page.
*/
nr_php_wrap_user_function(
NR_PSTR("Symfony\\Component\\HttpKernel\\"
"EventListener\\ExceptionListener::onKernelException"),
nr_symfony4_exception TSRMLS_CC);
if (!NRINI(ignore_framework_error_exception_handler)) {
nr_php_wrap_user_function(
NR_PSTR("Symfony\\Component\\HttpKernel\\"
"EventListener\\ExceptionListener::onKernelException"),
nr_symfony4_exception TSRMLS_CC);

/*
* In Symfony 5 listener that catch errors was changed to ErrorListener,
* we try to hook into it
*/
nr_php_wrap_user_function(
NR_PSTR("Symfony\\Component\\HttpKernel\\"
"EventListener\\ErrorListener::onKernelException"),
nr_symfony4_exception TSRMLS_CC);
/*
* In Symfony 5 listener that catch errors was changed to ErrorListener,
* we try to hook into it
*/
nr_php_wrap_user_function(
NR_PSTR("Symfony\\Component\\HttpKernel\\"
"EventListener\\ErrorListener::onKernelException"),
nr_symfony4_exception TSRMLS_CC);
}

/*
* Listen for Symfony commands so we can name those appropriately.
Expand Down
6 changes: 4 additions & 2 deletions agent/fw_yii.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ void nr_yii2_enable(TSRMLS_D) {
* allowing default PHP error handler to be intercepted by the NewRelic agent
* implementation.
*/
nr_php_wrap_user_function(NR_PSTR("yii\\base\\ErrorHandler::logException"),
nr_yii2_error_handler_wrapper TSRMLS_CC);
if (!NRINI(ignore_framework_error_exception_handler)) {
nr_php_wrap_user_function(NR_PSTR("yii\\base\\ErrorHandler::logException"),
nr_yii2_error_handler_wrapper TSRMLS_CC);
}
#endif

if (NRINI(vulnerability_management_package_detection_enabled)) {
Expand Down
3 changes: 3 additions & 0 deletions agent/php_newrelic.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ nrinibool_t
nrinibool_t
ignore_user_exception_handler; /* newrelic.error_collector.ignore_user_exception_handler
*/
nrinibool_t
ignore_framework_error_exception_handler; /* newrelic.error_collector.ignore_framework_error_excpetion_handler
*/
nriniint_t ignore_errors; /* newrelic.error_collector.ignore_errors */
nrinistr_t ignore_exceptions; /* newrelic.error_collector.ignore_exceptions */
nrinibool_t
Expand Down
8 changes: 8 additions & 0 deletions agent/php_nrini.c
Original file line number Diff line number Diff line change
Expand Up @@ -2587,6 +2587,14 @@ STD_PHP_INI_ENTRY_EX("newrelic.error_collector.ignore_user_exception_handler",
zend_newrelic_globals,
newrelic_globals,
nr_yes_no_dh)
STD_PHP_INI_ENTRY_EX("newrelic.error_collector.ignore_framework_error_exception_handler",
"0",
NR_PHP_REQUEST,
nr_boolean_mh,
ignore_framework_error_exception_handler,
zend_newrelic_globals,
newrelic_globals,
nr_yes_no_dh)
STD_PHP_INI_ENTRY_EX("newrelic.error_collector.ignore_errors",
"",
NR_PHP_REQUEST,
Expand Down
16 changes: 16 additions & 0 deletions agent/scripts/newrelic.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,22 @@ newrelic.daemon.logfile = "/var/log/newrelic/newrelic-daemon.log"
;
;newrelic.error_collector.ignore_user_exception_handler = false

; Setting: newrelic.error_collector.ignore_framework_error_exception_handler
; Type : boolean
; Scope : per-directory
; Default: false
; Info : If enabled, the New Relic error collector will ignore any errors or
; exceptions that are handled by a framework error or exception
; handler.
;
; This is useful if you only want to see exceptions that are re-
; thrown by the framework or if you are inserting your own
; handling logic into the exception handling stack that will
; filter errors/exceptions and manually call the New Relic API
; when instrumentation is desired.
;
;newrelic.error_collector.ignore_framework_error_exception_handler = false

; Setting: newrelic.error_collector.ignore_exceptions
; Type: string
; Scope: per-directory
Expand Down