From 2c9bf202e8479d76de3ab676500430b7509c89bf Mon Sep 17 00:00:00 2001 From: bduranleau-nr <106178551+bduranleau-nr@users.noreply.github.com> Date: Thu, 28 Mar 2024 14:29:26 -0500 Subject: [PATCH 01/44] ci: add workflow to trigger test suite workflows (#861) --- .github/workflows/trigger-test-suite.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/trigger-test-suite.yml diff --git a/.github/workflows/trigger-test-suite.yml b/.github/workflows/trigger-test-suite.yml new file mode 100644 index 000000000..f141241b7 --- /dev/null +++ b/.github/workflows/trigger-test-suite.yml @@ -0,0 +1,18 @@ +# Copyright 2020 New Relic Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# + +name: trigger-test-suite + +on: + pull_request: + +jobs: + trigger-multiverse-tests: + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.TEST_SUITE_REPO_GH_TOKEN }} + steps: + - name: Trigger Multiverse Test Suite + run: | + gh workflow run -R ${{ secrets.TEST_SUITE_REPO }} ${{ secrets.TEST_SUITE_WORKFLOW }} -f agent_git_ref=${{ github.head_ref }} -f pr-number=${{ github.event.number }} From 06d0436504b38fe379e604c1c8b5296d28faf15e Mon Sep 17 00:00:00 2001 From: Amber Sistla Date: Thu, 4 Apr 2024 17:58:08 -0700 Subject: [PATCH 02/44] test(integration): Add additional custom error handler tests (#869) Added additional tests to exercise a variety of return values from a custom error handler. --- .../errors/test_error_handler_false.php | 96 ++++++++++++++ .../errors/test_error_handler_implicit.php | 48 +++++++ .../errors/test_error_handler_true.php | 48 +++++++ .../test_error_handler_with_fatal_error.php | 100 +++++++++++++++ ...ror_handler_with_nonhandled_error_type.php | 121 ++++++++++++++++++ .../test_error_handler_with_strings.php | 81 ++++++++++++ .../test_error_handler_with_strings.php7.php | 57 +++++++++ 7 files changed, 551 insertions(+) create mode 100644 tests/integration/errors/test_error_handler_false.php create mode 100644 tests/integration/errors/test_error_handler_implicit.php create mode 100644 tests/integration/errors/test_error_handler_true.php create mode 100644 tests/integration/errors/test_error_handler_with_fatal_error.php create mode 100644 tests/integration/errors/test_error_handler_with_nonhandled_error_type.php create mode 100644 tests/integration/errors/test_error_handler_with_strings.php create mode 100644 tests/integration/errors/test_error_handler_with_strings.php7.php diff --git a/tests/integration/errors/test_error_handler_false.php b/tests/integration/errors/test_error_handler_false.php new file mode 100644 index 000000000..abadfc5a9 --- /dev/null +++ b/tests/integration/errors/test_error_handler_false.php @@ -0,0 +1,96 @@ +propName); + +//trigger an error that is not handled by the custom error handler +trigger_error("Let this serve as a deprecation", E_USER_DEPRECATED); + + diff --git a/tests/integration/errors/test_error_handler_with_strings.php b/tests/integration/errors/test_error_handler_with_strings.php new file mode 100644 index 000000000..a541d257e --- /dev/null +++ b/tests/integration/errors/test_error_handler_with_strings.php @@ -0,0 +1,81 @@ +propName); + +// generate "Attempt to read property" error +$bar = false; +echo ($bar->var); + +// generate "Undefined array key" error +$missingOneArray = array(2=>'two', 4=>'four'); +echo $missingOneArray[1]; + + + diff --git a/tests/integration/errors/test_error_handler_with_strings.php7.php b/tests/integration/errors/test_error_handler_with_strings.php7.php new file mode 100644 index 000000000..dba203539 --- /dev/null +++ b/tests/integration/errors/test_error_handler_with_strings.php7.php @@ -0,0 +1,57 @@ +propName); + + + From e0d2d122bc24518924e93c0208f2eb2b32ba7fb3 Mon Sep 17 00:00:00 2001 From: bduranleau-nr <106178551+bduranleau-nr@users.noreply.github.com> Date: Fri, 5 Apr 2024 12:58:49 -0500 Subject: [PATCH 03/44] fix(daemon): fix json struct tag for docker id (#870) --- daemon/internal/newrelic/utilization/utilization_hash.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/internal/newrelic/utilization/utilization_hash.go b/daemon/internal/newrelic/utilization/utilization_hash.go index f12c29148..7791dfee8 100644 --- a/daemon/internal/newrelic/utilization/utilization_hash.go +++ b/daemon/internal/newrelic/utilization/utilization_hash.go @@ -55,7 +55,7 @@ type Data struct { } type docker struct { - ID string `json:"id",omitempty` + ID string `json:"id,omitempty"` } type vendors struct { From 8f0ae2c08122235e292f0110601ed448d112eb62 Mon Sep 17 00:00:00 2001 From: Amber Sistla Date: Thu, 18 Apr 2024 10:27:22 -0700 Subject: [PATCH 04/44] fix(agent): Fix error reporting when EH_THROW is enabled (#876) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR 1)checks if EH_THROW(which signals to PHP to throw an exception from the error) is toggled and if so does not record an error because if uncaught it will be handled by the exception handler and if caught there's no need to record it. 2) add tests to verify fix More details: /* * For a the following error codes: * E_WARNING || E_CORE_WARNING || E_COMPILE_WARNING || E_USER_WARNING * PHP triggers an exception if EH_THROW is toggled on and then immediately * returns after throwing the exception. See for more info: * https://github.com/php/php-src/blob/master/main/main.c In that case, we * should not handle it, but we should exist and let the exception handler * deal with it; otherwise, we could record an error even if an exception is * caught. */ In the case where a php E_WARNING error was triggered.  We intercept the error from PHP and record it then pass execution back to PHP. But, for instance, in the particular case that deals with a filehandling which toggles EH_THROW on here: https://github.com/php/php-src/blob/master/ext/fileinfo/fileinfo.c#L176 PHP then handles the error but for a certain number of error codes, PHP triggers an exception if EH_THROW is toggled on: https://github.com/php/php-src/blob/master/main/main.c#L1254C1-L1259C24 and then immediately returns after throwing the exception. This leads to the case in the issue where the exception that was triggered is caught, but we recorded the error.... --- agent/php_error.c | 27 ++++- .../test_EH_THROW_errors_caught_exception.php | 69 +++++++++++ ...est_EH_THROW_errors_uncaught_exception.php | 112 ++++++++++++++++++ 3 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 tests/integration/errors/test_EH_THROW_errors_caught_exception.php create mode 100644 tests/integration/errors/test_EH_THROW_errors_uncaught_exception.php diff --git a/agent/php_error.c b/agent/php_error.c index 59956d585..539911dcc 100644 --- a/agent/php_error.c +++ b/agent/php_error.c @@ -561,12 +561,36 @@ static int nr_php_should_record_error(int type, const char* format TSRMLS_DC) { return 0; } + /* + * For a the following error types: + * E_WARNING || E_CORE_WARNING || E_COMPILE_WARNING || E_USER_WARNING + * PHP triggers an exception if EH_THROW is toggled on and then immediately + * returns after throwing the exception. PHP 7 additionally triggers an exception + * for E_RECOVERABLE_ERROR. + * See for more info: + * https://github.com/php/php-src/blob/master/main/main.c In that case, we + * should not handle it, but we should exit and let the exception handler + * deal with it; otherwise, we could record an error even if an exception is + * caught. + */ +#if ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO +#define E_ERRORS_THROWING_EXCEPTIONS (E_WARNING | E_CORE_WARNING | E_COMPILE_WARNING | E_USER_WARNING | E_RECOVERABLE_ERROR) +#else +#define E_ERRORS_THROWING_EXCEPTIONS (E_WARNING | E_CORE_WARNING | E_COMPILE_WARNING | E_USER_WARNING) +#endif + +#define E_THROWS_EXCEPTION(e) ((E_ERRORS_THROWING_EXCEPTIONS & e) == e) + + if (EG(error_handling) == EH_THROW && E_THROWS_EXCEPTION(type)) { + // let the exception handler deal with this error + return 0; + } + errprio = nr_php_error_get_priority(type); if (0 == errprio) { return 0; } - if (NR_SUCCESS != nr_txn_record_error_worthy(NRPRG(txn), errprio)) { return 0; } @@ -625,7 +649,6 @@ void nr_php_error_cb(int type, stack_json = nr_php_backtrace_to_json(0 TSRMLS_CC); errclass = nr_php_error_get_type_string(type); - nr_txn_record_error(NRPRG(txn), nr_php_error_get_priority(type), true, msg, errclass, stack_json); diff --git a/tests/integration/errors/test_EH_THROW_errors_caught_exception.php b/tests/integration/errors/test_EH_THROW_errors_caught_exception.php new file mode 100644 index 000000000..8aaff4a3f --- /dev/null +++ b/tests/integration/errors/test_EH_THROW_errors_caught_exception.php @@ -0,0 +1,69 @@ +getMessage()); +} diff --git a/tests/integration/errors/test_EH_THROW_errors_uncaught_exception.php b/tests/integration/errors/test_EH_THROW_errors_uncaught_exception.php new file mode 100644 index 000000000..1d277d874 --- /dev/null +++ b/tests/integration/errors/test_EH_THROW_errors_uncaught_exception.php @@ -0,0 +1,112 @@ + Date: Thu, 18 Apr 2024 15:12:54 -0500 Subject: [PATCH 05/44] fix: de-duplicate php package data (#871) adds a filter for package data already sent during the current connection instance to prevent sending duplicate data between harvests. --- daemon/internal/newrelic/app.go | 85 +++++++++++++++++++++- daemon/internal/newrelic/app_test.go | 51 +++++++++++++ daemon/internal/newrelic/harvest_test.go | 15 ++++ daemon/internal/newrelic/php_packages.go | 5 ++ daemon/internal/newrelic/processor.go | 3 + daemon/internal/newrelic/processor_test.go | 10 ++- 6 files changed, 161 insertions(+), 8 deletions(-) diff --git a/daemon/internal/newrelic/app.go b/daemon/internal/newrelic/app.go index 843c5ff98..5f39e553e 100644 --- a/daemon/internal/newrelic/app.go +++ b/daemon/internal/newrelic/app.go @@ -146,6 +146,7 @@ type App struct { HarvestTrigger HarvestTriggerFunc LastActivity time.Time Rules MetricRules + PhpPackages map[PhpPackagesKey]struct{} } func (app *App) String() string { @@ -180,6 +181,7 @@ func NewApp(info *AppInfo) *App { info: info, HarvestTrigger: nil, LastActivity: now, + PhpPackages: make(map[PhpPackagesKey]struct{}), } } @@ -303,10 +305,10 @@ func (app *App) NeedsConnectAttempt(now time.Time, backoff time.Duration) bool { return false } -//Since span events are not included in Faster Event Harvest due to concerns -//about downsampling within a distributed trace, the report period and harvest -//limit are reported separately in span_event_harvest_config instead of -//event_harvest_config. Combine them both into EventHarvestConfig here. +// Since span events are not included in Faster Event Harvest due to concerns +// about downsampling within a distributed trace, the report period and harvest +// limit are reported separately in span_event_harvest_config instead of +// event_harvest_config. Combine them both into EventHarvestConfig here. func combineEventConfig(ehc collector.EventHarvestConfig, sehc collector.SpanEventHarvestConfig) collector.EventHarvestConfig { ehc.EventConfigs.SpanEventConfig.Limit = sehc.SpanEventConfig.Limit ehc.EventConfigs.SpanEventConfig.ReportPeriod = sehc.SpanEventConfig.ReportPeriod @@ -338,3 +340,78 @@ func (app *App) Inactive(threshold time.Duration) bool { } return time.Since(app.LastActivity) > threshold } + +// filter seen php packages data to avoid sending duplicates +// +// the `App` structure contains a map of PHP Packages the reporting +// application has encountered. +// +// the map of packages should persist for the duration of the +// current connection +// +// takes the `PhpPackages.data` byte array as input and unmarshals +// into an anonymous interface array +// +// the JSON format received from the agent is: +// +// [["package_name","version",{}],...] +// +// for each entry, assign the package name and version to the `PhpPackagesKey` +// struct and use the key to verify data does not exist in the map. If the +// key does not exist, add it to the map and the array of 'new' packages. +// +// convert the array of 'new' packages into a byte array representing +// the expected data that should match input, minus the duplicates. +func (app *App) filterPhpPackages(data []byte) []byte { + if data == nil { + return nil + } + + var pkgKey PhpPackagesKey + var newPkgs []PhpPackagesKey + var x []interface{} + + err := json.Unmarshal(data, &x) + if nil != err { + log.Errorf("failed to unmarshal php package json: %s", err) + return nil + } + + for _, pkgJson := range x { + pkg, _ := pkgJson.([]interface{}) + if len(pkg) != 3 { + log.Errorf("invalid php package json structure: %+v", pkg) + return nil + } + name, ok := pkg[0].(string) + version, ok := pkg[1].(string) + pkgKey = PhpPackagesKey{name, version} + _, ok = app.PhpPackages[pkgKey] + if !ok { + app.PhpPackages[pkgKey] = struct{}{} + newPkgs = append(newPkgs, pkgKey) + } + } + + if newPkgs == nil { + return nil + } + + buf := &bytes.Buffer{} + buf.WriteString(`[`) + for _, pkg := range newPkgs { + buf.WriteString(`["`) + buf.WriteString(pkg.Name) + buf.WriteString(`","`) + buf.WriteString(pkg.Version) + buf.WriteString(`",{}],`) + } + + resJson := buf.Bytes() + + // swap last ',' character with ']' + resJson = resJson[:len(resJson)-1] + resJson = append(resJson, ']') + + return resJson +} diff --git a/daemon/internal/newrelic/app_test.go b/daemon/internal/newrelic/app_test.go index b61e5304f..2096f4802 100644 --- a/daemon/internal/newrelic/app_test.go +++ b/daemon/internal/newrelic/app_test.go @@ -613,3 +613,54 @@ func TestMaxPayloadSizeInBytesFromConnectReply(t *testing.T) { t.Errorf("parseConnectReply(something), got [%v], expected [%v]", c.MaxPayloadSizeInBytes, expectedMaxPayloadSizeInBytes) } } + +func TestFilterPhpPackages(t *testing.T) { + app := App{ + PhpPackages: make(map[PhpPackagesKey]struct{}), + } + var nilData []byte = nil + emptyData := []byte(`[[{}]]`) + validData := []byte(`[["drupal","6.0",{}]]`) + moreValidData := []byte(`[["wordpress","7.0",{}],["symfony","5.1",{}]]`) + duplicateData := []byte(`[["drupal","6.0",{}]]`) + versionData := []byte(`[["drupal","9.0",{}]]`) + invalidData := []byte(`[[["1","2","3"],["4","5"]{}]]`) + + filteredData := app.filterPhpPackages(nilData) + if filteredData != nil { + t.Errorf("expected 'nil' result on 'nil' input, got [%v]", filteredData) + } + + filteredData = app.filterPhpPackages(emptyData) + if filteredData != nil { + t.Errorf("expected 'nil' result on empty data input, got [%v]", filteredData) + } + + expect := []byte(`[["drupal","6.0",{}]]`) + filteredData = app.filterPhpPackages(validData) + if string(filteredData) != string(expect) { + t.Errorf("expected [%v], got [%v]", string(expect), string(filteredData)) + } + + expect = []byte(`[["wordpress","7.0",{}],["symfony","5.1",{}]]`) + filteredData = app.filterPhpPackages(moreValidData) + if string(filteredData) != string(expect) { + t.Errorf("expected [%v], got [%v]", string(expect), string(filteredData)) + } + + filteredData = app.filterPhpPackages(duplicateData) + if filteredData != nil { + t.Errorf("expected 'nil', got [%v]", filteredData) + } + + expect = []byte(`[["drupal","9.0",{}]]`) + filteredData = app.filterPhpPackages(versionData) + if string(filteredData) != string(expect) { + t.Errorf("expected [%v], got [%v]", string(expect), string(filteredData)) + } + + filteredData = app.filterPhpPackages(invalidData) + if filteredData != nil { + t.Errorf("expected 'nil', go [%v]", filteredData) + } +} diff --git a/daemon/internal/newrelic/harvest_test.go b/daemon/internal/newrelic/harvest_test.go index 02d8abd40..758bf0111 100644 --- a/daemon/internal/newrelic/harvest_test.go +++ b/daemon/internal/newrelic/harvest_test.go @@ -234,4 +234,19 @@ func TestHarvestEmpty(t *testing.T) { if h.empty() { t.Errorf("Harvest.empty() = true, want false") } + + // verify that php packages does not send harvest when data is nil + h = NewHarvest(startTime, collector.NewHarvestLimits(nil)) + h.PhpPackages.AddPhpPackagesFromData(nil) + if !h.empty() { + t.Errorf("Harvest.empty = false, want true") + } + + // verify that valid php package data sends a harvest + h = NewHarvest(startTime, collector.NewHarvestLimits(nil)) + h.PhpPackages.AddPhpPackagesFromData([]byte(`[["testpackage","testversion",{}]]`)) + if h.empty() { + t.Errorf("Harvest.empty = true, want false") + } + } diff --git a/daemon/internal/newrelic/php_packages.go b/daemon/internal/newrelic/php_packages.go index bf6397f5b..0e82e0648 100644 --- a/daemon/internal/newrelic/php_packages.go +++ b/daemon/internal/newrelic/php_packages.go @@ -13,6 +13,11 @@ import ( "github.com/newrelic/newrelic-php-agent/daemon/internal/newrelic/log" ) +type PhpPackagesKey struct { + Name string + Version string +} + // phpPackages represents all detected packages reported by an agent. type PhpPackages struct { numSeen int diff --git a/daemon/internal/newrelic/processor.go b/daemon/internal/newrelic/processor.go index 96d07f0b3..9b00cee1a 100644 --- a/daemon/internal/newrelic/processor.go +++ b/daemon/internal/newrelic/processor.go @@ -673,6 +673,8 @@ func harvestByType(ah *AppHarvest, args *harvestArgs, ht HarvestType, du_chan ch // In such cases, harvest all types and return. if ht&HarvestAll == HarvestAll { ah.Harvest = NewHarvest(time.Now(), ah.App.connectReply.EventHarvestConfig.EventConfigs) + // filter already seen php packages + harvest.PhpPackages.data = ah.App.filterPhpPackages(harvest.PhpPackages.data) if args.blocking { // Invoked primarily by CleanExit harvestAll(harvest, args, ah.connectReply.EventHarvestConfig, ah.TraceObserver, du_chan) @@ -698,6 +700,7 @@ func harvestByType(ah *AppHarvest, args *harvestArgs, ht HarvestType, du_chan ch slowSQLs := harvest.SlowSQLs txnTraces := harvest.TxnTraces phpPackages := harvest.PhpPackages + phpPackages.data = ah.App.filterPhpPackages(phpPackages.data) harvest.Metrics = NewMetricTable(limits.MaxMetrics, time.Now()) harvest.Errors = NewErrorHeap(limits.MaxErrors) diff --git a/daemon/internal/newrelic/processor_test.go b/daemon/internal/newrelic/processor_test.go index 1025439cc..4910535ab 100644 --- a/daemon/internal/newrelic/processor_test.go +++ b/daemon/internal/newrelic/processor_test.go @@ -64,7 +64,7 @@ var ( sampleSpanEvent = []byte("belated birthday") sampleLogEvent = []byte("log event test birthday") sampleErrorEvent = []byte("forgotten birthday") - samplePhpPackages = []byte(`["package", "1.2.3",{}]`) + samplePhpPackages = []byte(`[["package","1.2.3",{}]]`) ) type ClientReturn struct { @@ -297,9 +297,11 @@ func TestProcessorHarvestDefaultDataPhpPackages(t *testing.T) { // collect php packages m.clientReturn <- ClientReturn{nil, nil, 202} cp_pkgs := <-m.clientParams + // collect metrics m.clientReturn <- ClientReturn{nil, nil, 202} cp_metrics := <-m.clientParams + // collect usage metrics m.clientReturn <- ClientReturn{nil, nil, 202} cp_usage := <-m.clientParams @@ -308,7 +310,7 @@ func TestProcessorHarvestDefaultDataPhpPackages(t *testing.T) { // check pkgs and metric data - it appears these can // come in different orders so check both - toTestPkgs := `["Jars",["package", "1.2.3",{}]]` + toTestPkgs := `["Jars",[["package","1.2.3",{}]]]` if toTestPkgs != string(cp_pkgs.data) { if toTestPkgs != string(cp_metrics.data) { t.Fatalf("packages data: expected '%s', got '%s'", toTestPkgs, string(cp_pkgs.data)) @@ -318,9 +320,9 @@ func TestProcessorHarvestDefaultDataPhpPackages(t *testing.T) { time1 := strings.Split(string(cp_usage.data), ",")[1] time2 := strings.Split(string(cp_usage.data), ",")[2] usageMetrics := `["one",` + time1 + `,` + time2 + `,` + - `[[{"name":"Supportability/C/Collector/Output/Bytes"},[2,1285,0,0,0,0]],` + + `[[{"name":"Supportability/C/Collector/Output/Bytes"},[2,1286,0,0,0,0]],` + `[{"name":"Supportability/C/Collector/metric_data/Output/Bytes"},[1,1253,0,0,0,0]],` + - `[{"name":"Supportability/C/Collector/update_loaded_modules/Output/Bytes"},[1,32,0,0,0,0]]]]` + `[{"name":"Supportability/C/Collector/update_loaded_modules/Output/Bytes"},[1,33,0,0,0,0]]]]` if got, _ := OrderScrubMetrics(cp_usage.data, nil); string(got) != usageMetrics { t.Fatalf("metrics data: expected '%s', got '%s'", string(usageMetrics), string(got)) } From eecccd56ec3c5fb5bfab07295f9e39386d927c76 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Fri, 19 Apr 2024 09:19:35 -0400 Subject: [PATCH 06/44] fix(agent): improve exception handler instrumentation for PHPs 8.0+ (#877) When user exception handler is installed it can call restore_exception_handler, and that will reset is_exception_handler flag in the wraprec which will cause the agent not to use the correct code path after user exception handler returns. The information that nr_php_instrument_func_end is handling return from user exception handler needs to be stored in the segment associated with the user exception handler. --------- Co-authored-by: ZNeumann --- agent/php_execute.c | 10 +- axiom/nr_segment.h | 2 + .../test_uncaught_handled_exception_01.php | 170 ++++++++++++++++ .../test_uncaught_handled_exception_02.php | 168 ++++++++++++++++ .../test_uncaught_handled_exception_03.php | 175 +++++++++++++++++ .../test_uncaught_handled_exception_04.php | 184 ++++++++++++++++++ ...t_uncaught_handled_exception_04.php83a.php | 184 ++++++++++++++++++ ...t_uncaught_handled_exception_04.php83b.php | 177 +++++++++++++++++ 8 files changed, 1069 insertions(+), 1 deletion(-) create mode 100644 tests/integration/errors/test_uncaught_handled_exception_01.php create mode 100644 tests/integration/errors/test_uncaught_handled_exception_02.php create mode 100644 tests/integration/errors/test_uncaught_handled_exception_03.php create mode 100644 tests/integration/errors/test_uncaught_handled_exception_04.php create mode 100644 tests/integration/errors/test_uncaught_handled_exception_04.php83a.php create mode 100644 tests/integration/errors/test_uncaught_handled_exception_04.php83b.php diff --git a/agent/php_execute.c b/agent/php_execute.c index 7bb875ec1..f7ea011e5 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -1946,6 +1946,14 @@ static void nr_php_instrument_func_begin(NR_EXECUTE_PROTO) { if (NULL == wraprec) { return; } + + /* Store information that the segment is exception handler segment directly in + * the segment, because exception handler can call restore_exception_handler, + * and that will reset is_exception_handler flag in the wraprec */ + if (wraprec->is_exception_handler) { + segment->is_exception_handler = 1; + } + /* * If a function needs to have arguments modified, do so in * nr_zend_call_oapi_special_before. @@ -2027,7 +2035,7 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO) { wraprec = segment->wraprec; - if (wraprec && wraprec->is_exception_handler) { + if (segment->is_exception_handler) { /* * After running the exception handler segment, create an error from * the exception it handled, and save the error in the transaction. diff --git a/axiom/nr_segment.h b/axiom/nr_segment.h index 5d68e9226..56d972579 100644 --- a/axiom/nr_segment.h +++ b/axiom/nr_segment.h @@ -192,6 +192,8 @@ typedef struct _nr_segment_t { */ void* wraprec; /* wraprec, if one is associated with this segment, to reduce wraprec lookups */ + int is_exception_handler; /* 1 if segment is associated with exception + handler, 0 otherwise */ #endif } nr_segment_t; diff --git a/tests/integration/errors/test_uncaught_handled_exception_01.php b/tests/integration/errors/test_uncaught_handled_exception_01.php new file mode 100644 index 000000000..75b6ee3f4 --- /dev/null +++ b/tests/integration/errors/test_uncaught_handled_exception_01.php @@ -0,0 +1,170 @@ +=")) { + die("skip: PHP >= 8.3.0 not supported\n"); +} +*/ + + +/*EXPECT_ERROR_EVENTS*/ +/* +[ + "?? agent run id", + { + "reservoir_size": "??", + "events_seen": 1 + }, + [ + [ + { + "type": "TransactionError", + "timestamp": "??", + "error.class": "RuntimeException", + "error.message": "Uncaught exception 'RuntimeException' with message 'Expected unexpected happened' in __FILE__:??", + "transactionName": "OtherTransaction\/php__FILE__", + "duration": "??", + "nr.transactionGuid": "??", + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??", + "spanId": "??" + }, + {}, + "??" + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS*/ +/* +[ + "?? agent run id", + { + "reservoir_size": 10000, + "events_seen": 4 + }, + [ + [ + { + "category": "generic", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "OtherTransaction\/php__FILE__", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "nr.entryPoint": true, + "transaction.name": "OtherTransaction\/php__FILE__" + }, + {}, + {} + ], + [ + { + "category": "generic", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Custom\/call_throw_it", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??" + }, + {}, + { + "error.message": "Uncaught exception 'RuntimeException' with message 'Expected unexpected happened' in __FILE__:??", + "error.class": "RuntimeException" + } + ], + [ + { + "category": "generic", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Custom\/throw_it", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??" + }, + {}, + { + "error.message": "Uncaught exception 'RuntimeException' with message 'Expected unexpected happened' in __FILE__:??", + "error.class": "RuntimeException" + } + ], + [ + { + "category": "generic", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Custom\/user_exception_handler_02", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??" + }, + {}, + {} + ] + ] +] +*/ + + +/*EXPECT_REGEX +Fatal error: Uncaught RuntimeException: Not able to handle, throwing another exception from handler +*/ + +function user_exception_handler_01(Throwable $ex) { + echo "01 Handled uncaught exception"; +} + +function user_exception_handler_02(Throwable $ex) { + restore_exception_handler(); + throw new RuntimeException("Not able to handle, throwing another exception from handler"); + echo "Should never see this"; +} + +function throw_it() { + throw new RuntimeException('Expected unexpected happened'); +} + +function call_throw_it() { + throw_it(); +} + +set_exception_handler('user_exception_handler_01'); +set_exception_handler('user_exception_handler_02'); + +call_throw_it(); diff --git a/tests/integration/errors/test_uncaught_handled_exception_04.php83a.php b/tests/integration/errors/test_uncaught_handled_exception_04.php83a.php new file mode 100644 index 000000000..b71d37150 --- /dev/null +++ b/tests/integration/errors/test_uncaught_handled_exception_04.php83a.php @@ -0,0 +1,184 @@ +=")) { + die("skip: PHP >= 8.3.5 not supported\n"); +} +*/ + + +/*EXPECT_ERROR_EVENTS*/ +/* +[ + "?? agent run id", + { + "reservoir_size": "??", + "events_seen": 1 + }, + [ + [ + { + "type": "TransactionError", + "timestamp": "??", + "error.class": "RuntimeException", + "error.message": "Uncaught exception 'RuntimeException' with message 'Expected unexpected happened' in __FILE__:??", + "transactionName": "OtherTransaction\/php__FILE__", + "duration": "??", + "nr.transactionGuid": "??", + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??", + "spanId": "??" + }, + {}, + "??" + ] + ] +] +*/ + +/*EXPECT_SPAN_EVENTS*/ +/* +[ + "?? agent run id", + { + "reservoir_size": 10000, + "events_seen": 4 + }, + [ + [ + { + "category": "generic", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "OtherTransaction\/php__FILE__", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "nr.entryPoint": true, + "transaction.name": "OtherTransaction\/php__FILE__" + }, + {}, + {} + ], + [ + { + "category": "generic", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Custom\/call_throw_it", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??" + }, + {}, + { + "error.message": "Uncaught exception 'RuntimeException' with message 'Expected unexpected happened' in __FILE__:??", + "error.class": "RuntimeException" + } + ], + [ + { + "category": "generic", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Custom\/throw_it", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??" + }, + {}, + { + "error.message": "Uncaught exception 'RuntimeException' with message 'Expected unexpected happened' in __FILE__:??", + "error.class": "RuntimeException" + } + ], + [ + { + "category": "generic", + "type": "Span", + "guid": "??", + "traceId": "??", + "transactionId": "??", + "name": "Custom\/user_exception_handler_02", + "timestamp": "??", + "duration": "??", + "priority": "??", + "sampled": true, + "parentId": "??" + }, + {}, + {} + ] + ] +] +*/ + + +/*EXPECT_REGEX +01 Handled uncaught exception +*/ + +function user_exception_handler_01(Throwable $ex) { + echo "01 Handled uncaught exception"; +} + +function user_exception_handler_02(Throwable $ex) { + restore_exception_handler(); + throw new RuntimeException("Not able to handle, throwing another exception from handler"); + echo "Should never see this"; +} + +function throw_it() { + throw new RuntimeException('Expected unexpected happened'); +} + +function call_throw_it() { + throw_it(); +} + +set_exception_handler('user_exception_handler_01'); +set_exception_handler('user_exception_handler_02'); + +call_throw_it(); diff --git a/tests/integration/errors/test_uncaught_handled_exception_04.php83b.php b/tests/integration/errors/test_uncaught_handled_exception_04.php83b.php new file mode 100644 index 000000000..54f949619 --- /dev/null +++ b/tests/integration/errors/test_uncaught_handled_exception_04.php83b.php @@ -0,0 +1,177 @@ + Date: Fri, 19 Apr 2024 12:41:08 -0400 Subject: [PATCH 07/44] feat(agent): add support for Yii v2 (#848) Implement Yii v2 instrumentation for auto transaction naming. Original work by @razvanphp in #823. Fixes #821. --------- Co-authored-by: Razvan Grigore --- agent/fw_hooks.h | 3 +- agent/fw_yii.c | 140 ++++++++++++++++-- agent/php_execute.c | 6 +- agent/php_newrelic.h | 3 +- agent/scripts/newrelic.ini.template | 2 +- .../frameworks/yii/test_basic_cli.php | 22 +++ .../frameworks/yii/test_basic_web.php | 22 +++ .../frameworks/yii/yii2/baseyii.php | 46 ++++++ 8 files changed, 227 insertions(+), 17 deletions(-) create mode 100644 tests/integration/frameworks/yii/test_basic_cli.php create mode 100644 tests/integration/frameworks/yii/test_basic_web.php create mode 100644 tests/integration/frameworks/yii/yii2/baseyii.php diff --git a/agent/fw_hooks.h b/agent/fw_hooks.h index f49bc591b..baaf400c7 100644 --- a/agent/fw_hooks.h +++ b/agent/fw_hooks.h @@ -39,7 +39,8 @@ extern void nr_symfony4_enable(TSRMLS_D); extern void nr_silex_enable(TSRMLS_D); extern void nr_slim_enable(TSRMLS_D); extern void nr_wordpress_enable(TSRMLS_D); -extern void nr_yii_enable(TSRMLS_D); +extern void nr_yii1_enable(TSRMLS_D); +extern void nr_yii2_enable(TSRMLS_D); extern void nr_zend_enable(TSRMLS_D); extern void nr_fw_zend2_enable(TSRMLS_D); diff --git a/agent/fw_yii.c b/agent/fw_yii.c index c6ff7cef8..74aa19335 100644 --- a/agent/fw_yii.c +++ b/agent/fw_yii.c @@ -5,6 +5,7 @@ #include "php_agent.h" #include "php_call.h" #include "php_user_instrument.h" +#include "php_error.h" #include "php_execute.h" #include "php_wrapper.h" #include "fw_hooks.h" @@ -14,7 +15,7 @@ #include "util_strings.h" /* - * Set the web transaction name from the action. + * Yii1: Set the web transaction name from the controllerId + actionId combo. * * * txn naming scheme: * In this case, `nr_txn_set_path` is called before `NR_PHP_WRAPPER_CALL` with @@ -23,8 +24,7 @@ * ensure OAPI compatibility. This entails that the first wrapped call gets to * name the txn. */ - -NR_PHP_WRAPPER(nr_yii_runWithParams_wrapper) { +NR_PHP_WRAPPER(nr_yii1_runWithParams_wrapper) { zval* classz = NULL; zval* idz = NULL; zval* this_var = NULL; @@ -37,7 +37,7 @@ NR_PHP_WRAPPER(nr_yii_runWithParams_wrapper) { (void)wraprec; NR_UNUSED_SPECIALFN; - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_YII); + NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_YII1); this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); if (NULL == this_var) { @@ -76,8 +76,9 @@ NR_PHP_WRAPPER(nr_yii_runWithParams_wrapper) { NR_NOT_OK_TO_OVERWRITE); } } + nr_php_zval_free(&idz); } - + nr_php_zval_free(&classz); end: NR_PHP_WRAPPER_CALL; @@ -86,21 +87,138 @@ NR_PHP_WRAPPER(nr_yii_runWithParams_wrapper) { NR_PHP_WRAPPER_END /* - * Enable Yii instrumentation. + * Enable Yii1 instrumentation. */ -void nr_yii_enable(TSRMLS_D) { +void nr_yii1_enable(TSRMLS_D) { #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("CAction::runWithParams"), nr_yii_runWithParams_wrapper, NULL, + NR_PSTR("CAction::runWithParams"), nr_yii1_runWithParams_wrapper, NULL, NULL); nr_php_wrap_user_function_before_after_clean( - NR_PSTR("CInlineAction::runWithParams"), nr_yii_runWithParams_wrapper, + NR_PSTR("CInlineAction::runWithParams"), nr_yii1_runWithParams_wrapper, NULL, NULL); #else nr_php_wrap_user_function(NR_PSTR("CAction::runWithParams"), - nr_yii_runWithParams_wrapper TSRMLS_CC); + nr_yii1_runWithParams_wrapper TSRMLS_CC); nr_php_wrap_user_function(NR_PSTR("CInlineAction::runWithParams"), - nr_yii_runWithParams_wrapper TSRMLS_CC); + nr_yii1_runWithParams_wrapper TSRMLS_CC); +#endif +} + +/* + * Yii2: Set the web transaction name from the unique action ID. + */ +NR_PHP_WRAPPER(nr_yii2_runWithParams_wrapper) { + zval* this_var = NULL; + zval* unique_idz = NULL; + const char* unique_id = NULL; + nr_string_len_t unique_id_length; + char* transaction_name = NULL; + + (void)wraprec; + NR_UNUSED_SPECIALFN; + + NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_YII2); + + this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); + if (NULL == this_var) { + nrl_verbosedebug(NRL_FRAMEWORK, "Yii2: improper this"); + goto end; + } + + unique_idz = nr_php_call(this_var, "getUniqueId"); + if (nr_php_is_zval_non_empty_string(unique_idz)) { + unique_id = Z_STRVAL_P(unique_idz); + unique_id_length = Z_STRLEN_P(unique_idz); + + if (unique_id_length > 256) { + nrl_warning(NRL_FRAMEWORK, + "Yii2 unique ID is too long (> %d); Yii2 naming not used", + 256); + } else { + transaction_name = (char*)nr_alloca(unique_id_length + 1); + nr_strxcpy(transaction_name, unique_id, unique_id_length); + + nr_txn_set_path("Yii2", NRPRG(txn), transaction_name, NR_PATH_TYPE_ACTION, + NR_NOT_OK_TO_OVERWRITE); + } + } else { + nrl_verbosedebug(NRL_FRAMEWORK, + "getUniqueId does not return a non empty string (%d)", + Z_TYPE_P(unique_idz)); + } + nr_php_zval_free(&unique_idz); +end: + NR_PHP_WRAPPER_CALL; + + nr_php_scope_release(&this_var); +} +NR_PHP_WRAPPER_END + +#if ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO \ + || defined OVERWRITE_ZEND_EXECUTE_DATA +/* + * Yii2: Report errors and exceptions when built-in ErrorHandler is enabled. + */ +NR_PHP_WRAPPER(nr_yii2_error_handler_wrapper) { + zval* exception = NULL; + + NR_UNUSED_SPECIALFN; + (void)wraprec; + + NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_YII2); + + exception = nr_php_arg_get(1, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); + if (!nr_php_is_zval_valid_object(exception)) { + nrl_verbosedebug(NRL_FRAMEWORK, "%s: exception is NULL or not an object", + __func__); + goto end; + } + + if (NR_SUCCESS + != nr_php_error_record_exception( + NRPRG(txn), exception, nr_php_error_get_priority(E_ERROR), true, + "Uncaught exception ", &NRPRG(exception_filters) TSRMLS_CC)) { + nrl_verbosedebug(NRL_FRAMEWORK, "%s: unable to record exception", __func__); + } + +end: + nr_php_arg_release(&exception); +} +NR_PHP_WRAPPER_END +#endif + +/* + * Enable Yii2 instrumentation. + */ +void nr_yii2_enable(TSRMLS_D) { +#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("yii\\base\\Action::runWithParams"), + nr_yii2_runWithParams_wrapper, NULL, NULL); + nr_php_wrap_user_function_before_after_clean( + NR_PSTR("yii\\base\\InlineAction::runWithParams"), + nr_yii2_runWithParams_wrapper, NULL, NULL); +#else + nr_php_wrap_user_function(NR_PSTR("yii\\base\\Action::runWithParams"), + nr_yii2_runWithParams_wrapper TSRMLS_CC); + nr_php_wrap_user_function(NR_PSTR("yii\\base\\InlineAction::runWithParams"), + nr_yii2_runWithParams_wrapper TSRMLS_CC); + /* + * Wrap Yii2 global error and exception handling methods. + * Given that: ErrorHandler::handleException(), ::handleError() and + * ::handleFatalError() all call ::logException($exception) at the right time, + * we will wrap this one to cover all cases. + * @see + * https://github.com/yiisoft/yii2/blob/master/framework/base/ErrorHandler.php + * + * Note: one can also set YII_ENABLE_ERROR_HANDLER constant to FALSE, this way + * 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); #endif } diff --git a/agent/php_execute.c b/agent/php_execute.c index f7ea011e5..341502f6c 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -416,8 +416,9 @@ static const nr_framework_table_t all_frameworks[] = { {"WordPress", "wordpress", NR_PSTR("wp-config.php"), 0, nr_wordpress_enable, NR_FW_WORDPRESS}, - {"Yii", "yii", NR_PSTR("framework/yii.php"), 0, nr_yii_enable, NR_FW_YII}, - {"Yii", "yii", NR_PSTR("framework/yiilite.php"), 0, nr_yii_enable, NR_FW_YII}, + {"Yii", "yii", NR_PSTR("framework/yii.php"), 0, nr_yii1_enable, NR_FW_YII1}, + {"Yii", "yii", NR_PSTR("framework/yiilite.php"), 0, nr_yii1_enable, NR_FW_YII1}, + {"Yii2", "yii2", NR_PSTR("yii2/baseyii.php"), 0, nr_yii2_enable, NR_FW_YII2}, /* See above: Laminas, the successor to Zend, which shares much of the instrumentation implementation with Zend */ @@ -535,7 +536,6 @@ static nr_library_table_t libraries[] = { {"SilverStripe4", NR_PSTR("silverstripeserviceconfigurationlocator.php"), NULL}, {"Typo3", NR_PSTR("classes/typo3/flow/core/bootstrap.php"), NULL}, {"Typo3", NR_PSTR("typo3/sysext/core/classes/core/bootstrap.php"), NULL}, - {"Yii2", NR_PSTR("yii2/baseyii.php"), NULL}, /* * Other CMS (content management systems), detected only, but diff --git a/agent/php_newrelic.h b/agent/php_newrelic.h index 4b55ae3b3..e114a6464 100644 --- a/agent/php_newrelic.h +++ b/agent/php_newrelic.h @@ -167,7 +167,8 @@ typedef enum { NR_FW_SYMFONY2, NR_FW_SYMFONY4, NR_FW_WORDPRESS, - NR_FW_YII, + NR_FW_YII1, + NR_FW_YII2, NR_FW_ZEND, NR_FW_ZEND2, NR_FW_LAMINAS3, diff --git a/agent/scripts/newrelic.ini.template b/agent/scripts/newrelic.ini.template index d720e83c0..eb0d24b00 100644 --- a/agent/scripts/newrelic.ini.template +++ b/agent/scripts/newrelic.ini.template @@ -639,7 +639,7 @@ newrelic.daemon.logfile = "/var/log/newrelic/newrelic-daemon.log" ; Must be one of the following values: ; cakephp, codeigniter, drupal, drupal8, joomla, kohana, laravel, ; magento, magento2, mediawiki, slim, symfony2, symfony4, -; wordpress, yii, zend, zend2, no_framework +; wordpress, yii, yii2, zend, zend2, no_framework ; ; Note that "drupal" covers only Drupal 6 and 7 and "symfony2" ; now only supports Symfony 3.x. diff --git a/tests/integration/frameworks/yii/test_basic_cli.php b/tests/integration/frameworks/yii/test_basic_cli.php new file mode 100644 index 000000000..abae3bb06 --- /dev/null +++ b/tests/integration/frameworks/yii/test_basic_cli.php @@ -0,0 +1,22 @@ +runWithParams([]); diff --git a/tests/integration/frameworks/yii/test_basic_web.php b/tests/integration/frameworks/yii/test_basic_web.php new file mode 100644 index 000000000..b03af867c --- /dev/null +++ b/tests/integration/frameworks/yii/test_basic_web.php @@ -0,0 +1,22 @@ +runWithParams([]); diff --git a/tests/integration/frameworks/yii/yii2/baseyii.php b/tests/integration/frameworks/yii/yii2/baseyii.php new file mode 100644 index 000000000..f884c6853 --- /dev/null +++ b/tests/integration/frameworks/yii/yii2/baseyii.php @@ -0,0 +1,46 @@ +uniqid = $argument; + } + + public function getUniqueId ( ) { + return $this->uniqid; + } + + public function runWithParams($params) { + return; + } + } + + /* Console action */ + class InlineAction { + private $uniqid; + + public function __construct($id) { + $this->uniqid = $id; + } + + public function getUniqueId ( ) { + return $this->uniqid; + } + + public function runWithParams($params) { + return; + } + } + echo ""; +} From 5b964b49be76545fde5c1c35e0468ad91e70d3ee Mon Sep 17 00:00:00 2001 From: Hitesh Ahuja <108540135+hahuja2@users.noreply.github.com> Date: Fri, 19 Apr 2024 10:04:12 -0700 Subject: [PATCH 08/44] feat(agent): Add supportability metrics for packages that provide major version (#868) This PR creates a new supportability metric that will provide information on what major version of the package is being used. The packages that provide the major version and will send up this supportability metric are: - Drupal - Guzzle - Laravel - Monolog - Predis - Slim - Wordpress. --- agent/fw_drupal8.c | 10 ++- agent/fw_laravel.c | 6 +- agent/fw_slim.c | 25 ++++--- agent/fw_support.c | 35 ++++++++++ agent/fw_support.h | 13 ++++ agent/fw_wordpress.c | 9 ++- agent/lib_guzzle6.c | 14 +++- agent/lib_monolog.c | 9 ++- agent/lib_predis.c | 11 ++- agent/php_agent.c | 11 ++- agent/tests/test_fw_support.c | 69 +++++++++++++++++++ axiom/nr_txn.h | 3 +- .../integration/external/guzzle6/test_cat.php | 1 + .../integration/external/guzzle6/test_dt.php | 1 + .../test_dt_newrelic_header_disabled.php | 1 + .../external/guzzle6/test_dt_synthetics.php | 1 + .../test_dt_synthetics_logging_off.php | 1 + .../external/guzzle6/test_no_cat_no_dt.php | 1 + .../integration/external/guzzle7/test_cat.php | 1 + .../integration/external/guzzle7/test_dt.php | 1 + .../test_dt_newrelic_header_disabled.php | 1 + .../external/guzzle7/test_dt_synthetics.php | 1 + .../external/guzzle7/test_no_cat_no_dt.php | 1 + .../logging/monolog2/test_monolog_basic.php | 1 + .../monolog2/test_monolog_basic_clm.php | 1 + .../monolog2/test_monolog_basic_clm_off.php | 1 + .../logging/monolog2/test_monolog_cat.php | 1 + .../monolog2/test_monolog_context_default.php | 1 + .../test_monolog_context_exception.php | 1 + .../test_monolog_context_filter_extra1.php | 1 + .../test_monolog_context_filter_extra2.php | 1 + .../test_monolog_context_filter_extra3.php | 1 + .../test_monolog_context_filter_extra4.php | 1 + .../test_monolog_context_filter_extra5.php | 1 + .../test_monolog_context_filter_rule1.php | 1 + .../test_monolog_context_filter_rule10.php | 1 + .../test_monolog_context_filter_rule11.php | 1 + .../test_monolog_context_filter_rule2.php | 1 + .../test_monolog_context_filter_rule3.php | 1 + .../test_monolog_context_filter_rule4.php | 1 + .../test_monolog_context_filter_rule5.php | 1 + .../test_monolog_context_filter_rule6.php | 1 + .../test_monolog_context_filter_rule7.php | 1 + .../test_monolog_context_filter_rule8.php | 1 + .../test_monolog_context_filter_rule9.php | 1 + .../test_monolog_context_limits_1.php | 1 + .../test_monolog_context_limits_2.php | 1 + .../test_monolog_context_precedence_1.php | 1 + .../test_monolog_context_precedence_2.php | 1 + .../monolog2/test_monolog_context_simple.php | 1 + ...test_monolog_decoration_and_forwarding.php | 1 + .../monolog2/test_monolog_disable_metrics.php | 1 + .../monolog2/test_monolog_drop_empty.php | 1 + .../monolog2/test_monolog_escape_chars.php | 1 + .../test_monolog_large_message_limit.php | 1 + ...test_monolog_large_message_limit_drops.php | 1 + .../test_monolog_limit_log_events.php | 1 + .../test_monolog_limit_zero_events.php | 1 + ...log_events_max_samples_stored_invalid1.php | 1 + ...log_events_max_samples_stored_invalid2.php | 1 + ...log_events_max_samples_stored_invalid3.php | 1 + ...log_events_max_samples_stored_invalid4.php | 1 + .../test_monolog_log_level_filter.php | 1 + .../test_monolog_log_level_filter_invalid.php | 1 + .../test_monolog_truncate_long_msgs.php | 1 + .../logging/monolog3/test_monolog_basic.php | 1 + .../monolog3/test_monolog_basic_clm.php | 1 + .../monolog3/test_monolog_basic_clm_off.php | 1 + .../logging/monolog3/test_monolog_cat.php | 1 + .../monolog3/test_monolog_context_default.php | 1 + .../test_monolog_context_exception.php | 1 + .../test_monolog_context_filter_extra1.php | 1 + .../test_monolog_context_filter_extra2.php | 1 + .../test_monolog_context_filter_extra3.php | 1 + .../test_monolog_context_filter_extra4.php | 1 + .../test_monolog_context_filter_extra5.php | 1 + .../test_monolog_context_filter_rule1.php | 1 + .../test_monolog_context_filter_rule10.php | 1 + .../test_monolog_context_filter_rule11.php | 1 + .../test_monolog_context_filter_rule2.php | 1 + .../test_monolog_context_filter_rule3.php | 1 + .../test_monolog_context_filter_rule4.php | 1 + .../test_monolog_context_filter_rule5.php | 1 + .../test_monolog_context_filter_rule6.php | 1 + .../test_monolog_context_filter_rule7.php | 1 + .../test_monolog_context_filter_rule8.php | 1 + .../test_monolog_context_filter_rule9.php | 1 + .../test_monolog_context_limits_1.php | 1 + .../test_monolog_context_limits_2.php | 1 + .../test_monolog_context_precedence_1.php | 1 + .../test_monolog_context_precedence_2.php | 1 + .../monolog3/test_monolog_context_simple.php | 1 + ...test_monolog_decoration_and_forwarding.php | 1 + .../monolog3/test_monolog_disable_metrics.php | 1 + .../monolog3/test_monolog_drop_empty.php | 1 + .../monolog3/test_monolog_escape_chars.php | 1 + .../test_monolog_large_message_limit.php | 1 + ...test_monolog_large_message_limit_drops.php | 1 + .../test_monolog_limit_log_events.php | 1 + .../test_monolog_limit_zero_events.php | 1 + ...log_events_max_samples_stored_invalid1.php | 1 + ...log_events_max_samples_stored_invalid2.php | 1 + ...log_events_max_samples_stored_invalid3.php | 1 + ...log_events_max_samples_stored_invalid4.php | 1 + .../test_monolog_log_level_filter.php | 1 + .../test_monolog_log_level_filter_invalid.php | 1 + .../test_monolog_truncate_long_msgs.php | 1 + tests/integration/predis/predis.inc | 4 ++ tests/integration/predis/test_basic.php | 1 + .../predis/test_basic_logging_off.php | 1 + .../predis/test_basic_reporting_disabled.php | 1 + tests/integration/predis/test_pipeline.php | 1 + .../predis/test_pipeline_atomic.php | 1 + .../predis/test_pipeline_fire_and_forget.php | 1 + ...t_pipeline_fire_and_forget_logging_off.php | 1 + 115 files changed, 295 insertions(+), 26 deletions(-) diff --git a/agent/fw_drupal8.c b/agent/fw_drupal8.c index fbd04f315..6593e17a8 100644 --- a/agent/fw_drupal8.c +++ b/agent/fw_drupal8.c @@ -18,6 +18,8 @@ #include "util_memory.h" #include "util_strings.h" +#define PHP_PACKAGE_NAME "drupal/core" + /* * Purpose : Convenience function to handle adding a callback to a method, * given a class entry and a method name. This will check the @@ -684,7 +686,11 @@ void nr_drupal_version() { // Add php package to transaction if (nr_php_is_zval_valid_string(zval_version)) { char* version = Z_STRVAL_P(zval_version); - nr_txn_add_php_package(NRPRG(txn), "drupal/core", version); + if (NRINI(vulnerability_management_package_detection_enabled)) { + nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, version); + } + nr_fw_support_add_package_supportability_metric(NRPRG(txn), PHP_PACKAGE_NAME, + version); } nr_php_zval_free(&zval_version); @@ -753,7 +759,7 @@ void nr_drupal8_enable(TSRMLS_D) { } if (NRINI(vulnerability_management_package_detection_enabled)) { - nr_txn_add_php_package(NRPRG(txn), "drupal/core", + nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, PHP_PACKAGE_VERSION_UNKNOWN); } } diff --git a/agent/fw_laravel.c b/agent/fw_laravel.c index 8d35715d2..11718a7e6 100644 --- a/agent/fw_laravel.c +++ b/agent/fw_laravel.c @@ -24,6 +24,8 @@ #include "ext/standard/php_versioning.h" #include "Zend/zend_exceptions.h" +#define PHP_PACKAGE_NAME "laravel/framework" + /* * This instruments Laravel 4.0-5.0, inclusive. * There is no support for Laravel 3.X or earlier. @@ -959,8 +961,10 @@ NR_PHP_WRAPPER(nr_laravel_application_construct) { if (NRINI(vulnerability_management_package_detection_enabled)) { // Add php package to transaction - nr_txn_add_php_package(NRPRG(txn), "laravel/framework", version); + nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, version); } + nr_fw_support_add_package_supportability_metric(NRPRG(txn), PHP_PACKAGE_NAME, + version); if (version) { nrl_debug(NRL_FRAMEWORK, "Laravel version is " NRP_FMT, NRP_PHP(version)); diff --git a/agent/fw_slim.c b/agent/fw_slim.c index e810dd7f4..493e325a8 100644 --- a/agent/fw_slim.c +++ b/agent/fw_slim.c @@ -12,6 +12,8 @@ #include "fw_support.h" #include "util_logging.h" +#define PHP_PACKAGE_NAME "slim/slim" + static char* nr_slim_path_from_route(zval* route TSRMLS_DC) { zval* name = NULL; zval* pattern = NULL; @@ -119,8 +121,13 @@ NR_PHP_WRAPPER(nr_slim_application_construct) { version = nr_php_get_object_constant(this_var, "VERSION"); - // Add php package to transaction - nr_txn_add_php_package(NRPRG(txn), "slim/slim", version); + if (NRINI(vulnerability_management_package_detection_enabled)) { + // Add php package to transaction + nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, version); + } + + nr_fw_support_add_package_supportability_metric(NRPRG(txn), PHP_PACKAGE_NAME, + version); nr_free(version); nr_php_scope_release(&this_var); @@ -139,13 +146,11 @@ void nr_slim_enable(TSRMLS_D) { nr_php_wrap_user_function(NR_PSTR("Slim\\Routing\\Route::run"), nr_slim3_4_route_run TSRMLS_CC); - if (NRINI(vulnerability_management_package_detection_enabled)) { - /* Slim 2 does not have the same path as Slim 3/4 which is why - we need to separate these*/ - nr_php_wrap_user_function(NR_PSTR("Slim\\Slim::__construct"), - nr_slim_application_construct); + /* Slim 2 does not have the same path as Slim 3/4 which is why + we need to separate these*/ + nr_php_wrap_user_function(NR_PSTR("Slim\\Slim::__construct"), + nr_slim_application_construct); - nr_php_wrap_user_function(NR_PSTR("Slim\\App::__construct"), - nr_slim_application_construct); - } + nr_php_wrap_user_function(NR_PSTR("Slim\\App::__construct"), + nr_slim_application_construct); } diff --git a/agent/fw_support.c b/agent/fw_support.c index f615aef10..daff2692c 100644 --- a/agent/fw_support.c +++ b/agent/fw_support.c @@ -11,6 +11,8 @@ #include "util_memory.h" #include "util_strings.h" +#define MAJOR_VERSION_LENGTH 8 + void nr_php_framework_add_supportability_metric(const char* framework_name, const char* name TSRMLS_DC) { char buf[512]; @@ -52,3 +54,36 @@ void nr_fw_support_add_logging_supportability_metric(nrtxn_t* txn, nrm_force_add(txn->unscoped_metrics, metname, 0); nr_free(metname); } + +void nr_fw_support_add_package_supportability_metric( + nrtxn_t* txn, + const char* package_name, + const char* package_version) { + if (NULL == txn || NULL == package_name || NULL == package_version) { + return; + } + + char* metname = NULL; + char major_version[MAJOR_VERSION_LENGTH] = {0}; + + /* The below for loop checks if the major version of the package is more than + * one digit and keeps looping until a '.' is encountered or one of the + * conditions is met. + */ + for (int i = 0; package_version[i] && i < MAJOR_VERSION_LENGTH - 1; i++) { + if ('.' == package_version[i]) { + break; + } + major_version[i] = package_version[i]; + } + + if (NR_FW_UNSET == NRINI(force_framework)) { + metname = nr_formatf("Supportability/PHP/package/%s/%s/detected", + package_name, major_version); + } else { + metname = nr_formatf("Supportability/PHP/package/%s/%s/forced", + package_name, major_version); + } + nrm_force_add(txn->unscoped_metrics, metname, 0); + nr_free(metname); +} diff --git a/agent/fw_support.h b/agent/fw_support.h index 45c5f8269..5099a7d35 100644 --- a/agent/fw_support.h +++ b/agent/fw_support.h @@ -38,4 +38,17 @@ extern void nr_fw_support_add_logging_supportability_metric( const char* library_name, const bool is_enabled); +/* + * Purpose: Add 'Supportability/PHP/package/{package}/{version}/detected' metric + * + * Params : 1. Transaction object + * 2. Package name + * 3. Package version + * + */ +extern void nr_fw_support_add_package_supportability_metric( + nrtxn_t* txn, + const char* package_name, + const char* package_version); + #endif /* FW_SUPPORT_HDR */ diff --git a/agent/fw_wordpress.c b/agent/fw_wordpress.c index 874ab6cc8..55a0be5f0 100644 --- a/agent/fw_wordpress.c +++ b/agent/fw_wordpress.c @@ -21,6 +21,7 @@ #define NR_WORDPRESS_HOOK_PREFIX "Framework/WordPress/Hook/" #define NR_WORDPRESS_PLUGIN_PREFIX "Framework/WordPress/Plugin/" +#define PHP_PACKAGE_NAME "wordpress" static nr_regex_t* wordpress_hook_regex; @@ -809,7 +810,11 @@ void nr_wordpress_version() { if (SUCCESS == result) { if (nr_php_is_zval_valid_string(&retval)) { char* version = Z_STRVAL(retval); - nr_txn_add_php_package(NRPRG(txn), "wordpress", version); + if (NRINI(vulnerability_management_package_detection_enabled)) { + nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, version); + } + nr_fw_support_add_package_supportability_metric(NRPRG(txn), PHP_PACKAGE_NAME, + version); } zval_dtor(&retval); } @@ -865,7 +870,7 @@ void nr_wordpress_enable(TSRMLS_D) { #endif /* OAPI */ if (NRINI(vulnerability_management_package_detection_enabled)) { - nr_txn_add_php_package(NRPRG(txn), "wordpress", + nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, PHP_PACKAGE_VERSION_UNKNOWN); } } diff --git a/agent/lib_guzzle6.c b/agent/lib_guzzle6.c index 0f131b5d0..9038c2aaf 100644 --- a/agent/lib_guzzle6.c +++ b/agent/lib_guzzle6.c @@ -58,6 +58,8 @@ #include "ext/standard/php_var.h" +#define PHP_PACKAGE_NAME "guzzlehttp/guzzle" + /* * Since Guzzle 6 requires PHP 5.5.0 or later, we just won't build the Guzzle 6 * support on older versions and will instead provide simple stubs for the two @@ -350,12 +352,18 @@ NR_PHP_WRAPPER_START(nr_guzzle6_client_construct) { zval* retval; zval* this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS); + char* version = nr_php_get_object_constant(this_var, "VERSION"); + if (NULL == version) { + version = nr_php_get_object_constant(this_var, "MAJOR_VERSION"); + } + if (NRINI(vulnerability_management_package_detection_enabled)) { - char* version = nr_php_get_object_constant(this_var, "VERSION"); // Add php package to transaction - nr_txn_add_php_package(NRPRG(txn), "guzzlehttp/guzzle", version); - nr_free(version); + nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, version); } + nr_fw_support_add_package_supportability_metric(NRPRG(txn), PHP_PACKAGE_NAME, + version); + nr_free(version); (void)wraprec; NR_UNUSED_SPECIALFN; diff --git a/agent/lib_monolog.c b/agent/lib_monolog.c index 2216e1a06..667e33583 100644 --- a/agent/lib_monolog.c +++ b/agent/lib_monolog.c @@ -30,6 +30,9 @@ #define LOG_DECORATE_PROC_FUNC_NAME \ "newrelic_phpagent_monolog_decorating_processor" +#define PHP_PACKAGE_NAME "monolog/monolog" +#define MAJOR_VERSION_LENGTH 8 + /* * Purpose : Convert Monolog\Logger::API to integer * @@ -373,6 +376,10 @@ NR_PHP_WRAPPER(nr_monolog_logger_addrecord) { api = nr_monolog_version(this_var TSRMLS_CC); timestamp = nr_monolog_get_timestamp(api, argc, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); + char version[MAJOR_VERSION_LENGTH]; + snprintf(version, sizeof(version), "%d", api); + nr_fw_support_add_package_supportability_metric(NRPRG(txn), + PHP_PACKAGE_NAME, version); } /* Record the log event */ @@ -513,7 +520,7 @@ void nr_monolog_enable(TSRMLS_D) { nr_monolog_logger_addrecord TSRMLS_CC); if (NRINI(vulnerability_management_package_detection_enabled)) { - nr_txn_add_php_package(NRPRG(txn), "monolog/monolog", + nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, PHP_PACKAGE_VERSION_UNKNOWN); } } diff --git a/agent/lib_predis.c b/agent/lib_predis.c index d4a287a03..862649d3b 100644 --- a/agent/lib_predis.c +++ b/agent/lib_predis.c @@ -19,6 +19,8 @@ #include "util_strings.h" #include "lib_predis_private.h" +#define PHP_PACKAGE_NAME "predis/predis" + /* * Predis instrumentation * ====================== @@ -646,12 +648,15 @@ NR_PHP_WRAPPER(nr_predis_client_construct) { (void)wraprec; NR_PHP_WRAPPER_CALL; + + char* version = nr_php_get_object_constant(scope, "VERSION"); if (NRINI(vulnerability_management_package_detection_enabled)) { - char* version = nr_php_get_object_constant(scope, "VERSION"); // Add php package to transaction - nr_txn_add_php_package(NRPRG(txn), "predis/predis", version); - nr_free(version); + nr_txn_add_php_package(NRPRG(txn), PHP_PACKAGE_NAME, version); } + nr_fw_support_add_package_supportability_metric(NRPRG(txn), PHP_PACKAGE_NAME, + version); + nr_free(version); /* * Grab the connection object from the client, since we actually instrument diff --git a/agent/php_agent.c b/agent/php_agent.c index 4d2fabf70..50d942b62 100644 --- a/agent/php_agent.c +++ b/agent/php_agent.c @@ -727,10 +727,15 @@ char* nr_php_get_object_constant(zval* app, const char* name) { if (nr_php_is_zval_valid_string(version)) { retval = nr_strndup(Z_STRVAL_P(version), Z_STRLEN_P(version)); + } else if (nr_php_is_zval_valid_integer(version)) { + zend_string* zstr = zend_long_to_str(Z_LVAL_P(version)); + retval = nr_strndup(ZSTR_VAL(zstr), ZSTR_LEN(zstr)); + zend_string_release(zstr); } else { - nrl_verbosedebug(NRL_FRAMEWORK, - "%s: expected VERSION be a valid string, got type %d", - __func__, Z_TYPE_P(version)); + nrl_verbosedebug( + NRL_FRAMEWORK, + "%s: expected VERSION to be a valid string or int, got type %d", + __func__, Z_TYPE_P(version)); } nr_php_zval_free(&version); diff --git a/agent/tests/test_fw_support.c b/agent/tests/test_fw_support.c index 907330ee9..c8b8e021d 100644 --- a/agent/tests/test_fw_support.c +++ b/agent/tests/test_fw_support.c @@ -13,8 +13,16 @@ tlib_parallel_info_t parallel_info static void test_fw_supportability_metrics(void) { #define LIBRARY_NAME "php-package" +#define LIBRARY_MAJOR_VERSION "7" +#define LIBRARY_MAJOR_VERSION_2 "10" +#define LIBRARY_MAJOR_VERSION_3 "100" +#define LIBRARY_MAJOR_VERSION_4 "1.23" +#define LIBRARY_MAJOR_VERSION_5 "12.34" +#define LIBRARY_MAJOR_VERSION_6 "123.45" +#define LIBRARY_MAJOR_VERSION_7 "0.4.5" #define LIBRARY_METRIC "Supportability/library/" LIBRARY_NAME "/detected" #define LOGGING_LIBRARY_METRIC "Supportability/Logging/PHP/" LIBRARY_NAME +#define PACKAGE_METRIC "Supportability/PHP/package/" LIBRARY_NAME nrtxn_t t; nrtxn_t* txn = &t; txn->unscoped_metrics = nrm_table_create(10); @@ -36,6 +44,18 @@ static void test_fw_supportability_metrics(void) { tlib_pass_if_int_equal("NULL logging library metric not created", 0, nrm_table_size(txn->unscoped_metrics)); + nr_fw_support_add_package_supportability_metric(NULL, LIBRARY_NAME, LIBRARY_MAJOR_VERSION); + tlib_pass_if_int_equal("package metric not created in NULL metrics", + 0, nrm_table_size(txn->unscoped_metrics)); + + nr_fw_support_add_package_supportability_metric(txn, NULL, LIBRARY_MAJOR_VERSION); + tlib_pass_if_int_equal("NULL package name, metric not created", 0, + nrm_table_size(txn->unscoped_metrics)); + + nr_fw_support_add_package_supportability_metric(txn, LIBRARY_NAME, NULL); + tlib_pass_if_int_equal("NULL major version, metric not created", 0, + nrm_table_size(txn->unscoped_metrics)); + /* Happy path */ nr_fw_support_add_library_supportability_metric(txn, LIBRARY_NAME); tlib_pass_if_not_null("happy path: library metric created", @@ -51,6 +71,55 @@ static void test_fw_supportability_metrics(void) { "happy path: logging library metric created", nrm_find(txn->unscoped_metrics, LOGGING_LIBRARY_METRIC "/disabled")); + nr_fw_support_add_package_supportability_metric(txn, LIBRARY_NAME, + LIBRARY_MAJOR_VERSION); + tlib_pass_if_not_null("happy path test 1: package metric created", + nrm_find(txn->unscoped_metrics, PACKAGE_METRIC + "/" LIBRARY_MAJOR_VERSION "/detected")); + + nr_fw_support_add_package_supportability_metric(txn, LIBRARY_NAME, + LIBRARY_MAJOR_VERSION_2); + tlib_pass_if_not_null("happy path test 2: package metric created", + nrm_find(txn->unscoped_metrics, PACKAGE_METRIC + "/" LIBRARY_MAJOR_VERSION_2 "/detected")); + + nr_fw_support_add_package_supportability_metric(txn, LIBRARY_NAME, + LIBRARY_MAJOR_VERSION_3); + tlib_pass_if_not_null("happy path test 3: package metric created", + nrm_find(txn->unscoped_metrics, PACKAGE_METRIC + "/" LIBRARY_MAJOR_VERSION_3 "/detected")); + + nr_fw_support_add_package_supportability_metric(txn, LIBRARY_NAME, + LIBRARY_MAJOR_VERSION_4); + tlib_pass_if_not_null( + "happy path test 4: package metric created", + nrm_find(txn->unscoped_metrics, PACKAGE_METRIC "/1/detected")); + + nr_fw_support_add_package_supportability_metric(txn, LIBRARY_NAME, + LIBRARY_MAJOR_VERSION_5); + tlib_pass_if_not_null( + "happy path test 5: package metric created", + nrm_find(txn->unscoped_metrics, PACKAGE_METRIC "/12/detected")); + + nr_fw_support_add_package_supportability_metric(txn, LIBRARY_NAME, + LIBRARY_MAJOR_VERSION_6); + tlib_pass_if_not_null( + "happy path test 6: package metric created", + nrm_find(txn->unscoped_metrics, PACKAGE_METRIC "/123/detected")); + + nr_fw_support_add_package_supportability_metric(txn, LIBRARY_NAME, + LIBRARY_MAJOR_VERSION_7); + tlib_pass_if_not_null( + "happy path test 7: package metric created", + nrm_find(txn->unscoped_metrics, PACKAGE_METRIC "/0/detected")); + + NRINI(force_framework) = true; + nr_fw_support_add_package_supportability_metric(txn, LIBRARY_NAME, + LIBRARY_MAJOR_VERSION); + tlib_pass_if_not_null( + "happy path test 8: package metric created", + nrm_find(txn->unscoped_metrics, PACKAGE_METRIC "/7/forced")); + nrm_table_destroy(&txn->unscoped_metrics); } diff --git a/axiom/nr_txn.h b/axiom/nr_txn.h index 01f085624..dc2cf014b 100644 --- a/axiom/nr_txn.h +++ b/axiom/nr_txn.h @@ -1161,7 +1161,8 @@ static inline nr_segment_t* nr_txn_allocate_segment(nrtxn_t* txn) { } /* - * Purpose : Add php packages to transaction + * Purpose : Add php packages to transaction. This function should only be + * called when Vulnerability Management is enabled. * * Params : 1. The transaction * 2. Package name diff --git a/tests/integration/external/guzzle6/test_cat.php b/tests/integration/external/guzzle6/test_cat.php index d2f3ac76e..9f4b40f2c 100644 --- a/tests/integration/external/guzzle6/test_cat.php +++ b/tests/integration/external/guzzle6/test_cat.php @@ -51,6 +51,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/6/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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 bb4cce2b2..da4d6584c 100644 --- a/tests/integration/external/guzzle6/test_dt.php +++ b/tests/integration/external/guzzle6/test_dt.php @@ -42,6 +42,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/6/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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 8ee9d895a..ad87177dd 100644 --- a/tests/integration/external/guzzle6/test_dt_newrelic_header_disabled.php +++ b/tests/integration/external/guzzle6/test_dt_newrelic_header_disabled.php @@ -43,6 +43,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/6/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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 67be5027f..ce80463ad 100644 --- a/tests/integration/external/guzzle6/test_dt_synthetics.php +++ b/tests/integration/external/guzzle6/test_dt_synthetics.php @@ -65,6 +65,7 @@ [{"name":"WebTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"WebTransactionTotalTime/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"HttpDispatcher"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/6/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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 9d2a739ed..c843f9571 100644 --- a/tests/integration/external/guzzle6/test_dt_synthetics_logging_off.php +++ b/tests/integration/external/guzzle6/test_dt_synthetics_logging_off.php @@ -68,6 +68,7 @@ [{"name":"WebTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"WebTransactionTotalTime/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"HttpDispatcher"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/6/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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 218f019ff..eb60de85c 100644 --- a/tests/integration/external/guzzle6/test_no_cat_no_dt.php +++ b/tests/integration/external/guzzle6/test_no_cat_no_dt.php @@ -42,6 +42,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/6/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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 48e5c3060..23686fa53 100644 --- a/tests/integration/external/guzzle7/test_cat.php +++ b/tests/integration/external/guzzle7/test_cat.php @@ -51,6 +51,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/7/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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/guzzle7/test_dt.php b/tests/integration/external/guzzle7/test_dt.php index 613f9dd94..0b82d6efb 100644 --- a/tests/integration/external/guzzle7/test_dt.php +++ b/tests/integration/external/guzzle7/test_dt.php @@ -42,6 +42,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/7/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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 28771bd59..6587c3e4c 100644 --- a/tests/integration/external/guzzle7/test_dt_newrelic_header_disabled.php +++ b/tests/integration/external/guzzle7/test_dt_newrelic_header_disabled.php @@ -43,6 +43,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/7/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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_synthetics.php b/tests/integration/external/guzzle7/test_dt_synthetics.php index 809a9298d..dd293905b 100644 --- a/tests/integration/external/guzzle7/test_dt_synthetics.php +++ b/tests/integration/external/guzzle7/test_dt_synthetics.php @@ -65,6 +65,7 @@ [{"name":"WebTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"WebTransactionTotalTime/Uri__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"HttpDispatcher"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/7/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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_no_cat_no_dt.php b/tests/integration/external/guzzle7/test_no_cat_no_dt.php index 383b2c0fb..ad1996e3a 100644 --- a/tests/integration/external/guzzle7/test_no_cat_no_dt.php +++ b/tests/integration/external/guzzle7/test_no_cat_no_dt.php @@ -42,6 +42,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/7/detected"}, [1, "??", "??", "??", "??", "??"]], [{"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/logging/monolog2/test_monolog_basic.php b/tests/integration/logging/monolog2/test_monolog_basic.php index 50003fb6e..b562bf15e 100644 --- a/tests/integration/logging/monolog2/test_monolog_basic.php +++ b/tests/integration/logging/monolog2/test_monolog_basic.php @@ -58,6 +58,7 @@ [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]] diff --git a/tests/integration/logging/monolog2/test_monolog_basic_clm.php b/tests/integration/logging/monolog2/test_monolog_basic_clm.php index 50f234e57..5ed62d3b3 100644 --- a/tests/integration/logging/monolog2/test_monolog_basic_clm.php +++ b/tests/integration/logging/monolog2/test_monolog_basic_clm.php @@ -45,6 +45,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_basic_clm_off.php b/tests/integration/logging/monolog2/test_monolog_basic_clm_off.php index c997317e7..3c656ac97 100644 --- a/tests/integration/logging/monolog2/test_monolog_basic_clm_off.php +++ b/tests/integration/logging/monolog2/test_monolog_basic_clm_off.php @@ -44,6 +44,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_cat.php b/tests/integration/logging/monolog2/test_monolog_cat.php index 97a61b77d..d96e38aec 100644 --- a/tests/integration/logging/monolog2/test_monolog_cat.php +++ b/tests/integration/logging/monolog2/test_monolog_cat.php @@ -56,6 +56,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_default.php b/tests/integration/logging/monolog2/test_monolog_context_default.php index 5fbc32cf0..859ce1ffe 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_default.php +++ b/tests/integration/logging/monolog2/test_monolog_context_default.php @@ -44,6 +44,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_exception.php b/tests/integration/logging/monolog2/test_monolog_context_exception.php index 16b62e5b4..c806bddc8 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_exception.php +++ b/tests/integration/logging/monolog2/test_monolog_context_exception.php @@ -46,6 +46,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_extra1.php b/tests/integration/logging/monolog2/test_monolog_context_filter_extra1.php index fb318cdc3..13875a0a6 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_extra1.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_extra1.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_extra2.php b/tests/integration/logging/monolog2/test_monolog_context_filter_extra2.php index 5867f935c..b55735e92 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_extra2.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_extra2.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_extra3.php b/tests/integration/logging/monolog2/test_monolog_context_filter_extra3.php index 92812d6bd..e90245135 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_extra3.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_extra3.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_extra4.php b/tests/integration/logging/monolog2/test_monolog_context_filter_extra4.php index 84c0fdfcc..dc232b6dc 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_extra4.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_extra4.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_extra5.php b/tests/integration/logging/monolog2/test_monolog_context_filter_extra5.php index e29b78368..1d3934a1d 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_extra5.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_extra5.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule1.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule1.php index bebe8489b..0cb138798 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule1.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule1.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule10.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule10.php index 3a817bb7e..eeff02ad8 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule10.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule10.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule11.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule11.php index 71e268443..854579344 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule11.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule11.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule2.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule2.php index 87f4f3968..2b7847f73 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule2.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule2.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule3.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule3.php index bb65ea6b7..864173103 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule3.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule3.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule4.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule4.php index 09f13b10c..3f2f01cdd 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule4.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule4.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule5.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule5.php index 252180a7b..ed6e512b5 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule5.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule5.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule6.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule6.php index 799336ee5..22ec5cebe 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule6.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule6.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule7.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule7.php index 55bc44caa..f9be37447 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule7.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule7.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule8.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule8.php index d63c67184..9e36e3bcb 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule8.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule8.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_filter_rule9.php b/tests/integration/logging/monolog2/test_monolog_context_filter_rule9.php index b1be23aec..ba6ba4cc7 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_filter_rule9.php +++ b/tests/integration/logging/monolog2/test_monolog_context_filter_rule9.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_limits_1.php b/tests/integration/logging/monolog2/test_monolog_context_limits_1.php index 72245794f..a01498ead 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_limits_1.php +++ b/tests/integration/logging/monolog2/test_monolog_context_limits_1.php @@ -45,6 +45,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_limits_2.php b/tests/integration/logging/monolog2/test_monolog_context_limits_2.php index 300365203..213b7379a 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_limits_2.php +++ b/tests/integration/logging/monolog2/test_monolog_context_limits_2.php @@ -45,6 +45,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_precedence_1.php b/tests/integration/logging/monolog2/test_monolog_context_precedence_1.php index 94b6b9069..6d571330c 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_precedence_1.php +++ b/tests/integration/logging/monolog2/test_monolog_context_precedence_1.php @@ -48,6 +48,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_precedence_2.php b/tests/integration/logging/monolog2/test_monolog_context_precedence_2.php index 1401e6571..7bf8b13ce 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_precedence_2.php +++ b/tests/integration/logging/monolog2/test_monolog_context_precedence_2.php @@ -48,6 +48,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_context_simple.php b/tests/integration/logging/monolog2/test_monolog_context_simple.php index f29ab92d8..769694845 100644 --- a/tests/integration/logging/monolog2/test_monolog_context_simple.php +++ b/tests/integration/logging/monolog2/test_monolog_context_simple.php @@ -59,6 +59,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_decoration_and_forwarding.php b/tests/integration/logging/monolog2/test_monolog_decoration_and_forwarding.php index 01ce34da8..1737a919c 100644 --- a/tests/integration/logging/monolog2/test_monolog_decoration_and_forwarding.php +++ b/tests/integration/logging/monolog2/test_monolog_decoration_and_forwarding.php @@ -113,6 +113,7 @@ [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/api/get_linking_metadata"}, [16, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_disable_metrics.php b/tests/integration/logging/monolog2/test_monolog_disable_metrics.php index 9f9682652..95b84d636 100644 --- a/tests/integration/logging/monolog2/test_monolog_disable_metrics.php +++ b/tests/integration/logging/monolog2/test_monolog_disable_metrics.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_drop_empty.php b/tests/integration/logging/monolog2/test_monolog_drop_empty.php index e9d236e77..8139e3606 100644 --- a/tests/integration/logging/monolog2/test_monolog_drop_empty.php +++ b/tests/integration/logging/monolog2/test_monolog_drop_empty.php @@ -57,6 +57,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_escape_chars.php b/tests/integration/logging/monolog2/test_monolog_escape_chars.php index 6018682f0..b95a67b1f 100644 --- a/tests/integration/logging/monolog2/test_monolog_escape_chars.php +++ b/tests/integration/logging/monolog2/test_monolog_escape_chars.php @@ -38,6 +38,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_large_message_limit.php b/tests/integration/logging/monolog2/test_monolog_large_message_limit.php index a6790497b..d7c9b677a 100644 --- a/tests/integration/logging/monolog2/test_monolog_large_message_limit.php +++ b/tests/integration/logging/monolog2/test_monolog_large_message_limit.php @@ -40,6 +40,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [833, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_large_message_limit_drops.php b/tests/integration/logging/monolog2/test_monolog_large_message_limit_drops.php index f21657f53..0dfe1dc2d 100644 --- a/tests/integration/logging/monolog2/test_monolog_large_message_limit_drops.php +++ b/tests/integration/logging/monolog2/test_monolog_large_message_limit_drops.php @@ -40,6 +40,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1666, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_limit_log_events.php b/tests/integration/logging/monolog2/test_monolog_limit_log_events.php index ea2104892..c9106b2ea 100644 --- a/tests/integration/logging/monolog2/test_monolog_limit_log_events.php +++ b/tests/integration/logging/monolog2/test_monolog_limit_log_events.php @@ -58,6 +58,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_limit_zero_events.php b/tests/integration/logging/monolog2/test_monolog_limit_zero_events.php index 0aa718275..6ff0fa7d1 100644 --- a/tests/integration/logging/monolog2/test_monolog_limit_zero_events.php +++ b/tests/integration/logging/monolog2/test_monolog_limit_zero_events.php @@ -58,6 +58,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid1.php b/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid1.php index 28a670681..f760b19ac 100644 --- a/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid1.php +++ b/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid1.php @@ -45,6 +45,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [833, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid2.php b/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid2.php index 0999ba3b0..ada730ed7 100644 --- a/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid2.php +++ b/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid2.php @@ -45,6 +45,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [833, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid3.php b/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid3.php index afb9e5bbb..cdd99bc5f 100644 --- a/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid3.php +++ b/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid3.php @@ -45,6 +45,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [833, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid4.php b/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid4.php index 8696024df..354108a09 100644 --- a/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid4.php +++ b/tests/integration/logging/monolog2/test_monolog_log_events_max_samples_stored_invalid4.php @@ -45,6 +45,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [833, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog2/test_monolog_log_level_filter.php b/tests/integration/logging/monolog2/test_monolog_log_level_filter.php index f24a2a62f..939dd9cf5 100644 --- a/tests/integration/logging/monolog2/test_monolog_log_level_filter.php +++ b/tests/integration/logging/monolog2/test_monolog_log_level_filter.php @@ -60,6 +60,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog2/test_monolog_log_level_filter_invalid.php b/tests/integration/logging/monolog2/test_monolog_log_level_filter_invalid.php index 6259670f0..d2eac9410 100644 --- a/tests/integration/logging/monolog2/test_monolog_log_level_filter_invalid.php +++ b/tests/integration/logging/monolog2/test_monolog_log_level_filter_invalid.php @@ -61,6 +61,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog2/test_monolog_truncate_long_msgs.php b/tests/integration/logging/monolog2/test_monolog_truncate_long_msgs.php index db912a727..4b8303eb1 100644 --- a/tests/integration/logging/monolog2/test_monolog_truncate_long_msgs.php +++ b/tests/integration/logging/monolog2/test_monolog_truncate_long_msgs.php @@ -43,6 +43,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_basic.php b/tests/integration/logging/monolog3/test_monolog_basic.php index 538d5c9c9..5cbc3a1da 100644 --- a/tests/integration/logging/monolog3/test_monolog_basic.php +++ b/tests/integration/logging/monolog3/test_monolog_basic.php @@ -56,6 +56,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_basic_clm.php b/tests/integration/logging/monolog3/test_monolog_basic_clm.php index 675f292bb..8fe6f3613 100644 --- a/tests/integration/logging/monolog3/test_monolog_basic_clm.php +++ b/tests/integration/logging/monolog3/test_monolog_basic_clm.php @@ -44,6 +44,7 @@ [{"name": "OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_basic_clm_off.php b/tests/integration/logging/monolog3/test_monolog_basic_clm_off.php index 2ca2e988c..e4ed19192 100644 --- a/tests/integration/logging/monolog3/test_monolog_basic_clm_off.php +++ b/tests/integration/logging/monolog3/test_monolog_basic_clm_off.php @@ -44,6 +44,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_cat.php b/tests/integration/logging/monolog3/test_monolog_cat.php index 1c68774d4..dcf557213 100644 --- a/tests/integration/logging/monolog3/test_monolog_cat.php +++ b/tests/integration/logging/monolog3/test_monolog_cat.php @@ -56,6 +56,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_default.php b/tests/integration/logging/monolog3/test_monolog_context_default.php index f5dde42ad..9080370e6 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_default.php +++ b/tests/integration/logging/monolog3/test_monolog_context_default.php @@ -44,6 +44,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_exception.php b/tests/integration/logging/monolog3/test_monolog_context_exception.php index 900b614cc..f64a6fc29 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_exception.php +++ b/tests/integration/logging/monolog3/test_monolog_context_exception.php @@ -46,6 +46,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_extra1.php b/tests/integration/logging/monolog3/test_monolog_context_filter_extra1.php index 443dc5248..7eed2a0b7 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_extra1.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_extra1.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_extra2.php b/tests/integration/logging/monolog3/test_monolog_context_filter_extra2.php index ce5d41251..7949d2f62 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_extra2.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_extra2.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_extra3.php b/tests/integration/logging/monolog3/test_monolog_context_filter_extra3.php index 3abd81c6a..c55dda857 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_extra3.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_extra3.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_extra4.php b/tests/integration/logging/monolog3/test_monolog_context_filter_extra4.php index 2d7dcac60..842d5f85b 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_extra4.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_extra4.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_extra5.php b/tests/integration/logging/monolog3/test_monolog_context_filter_extra5.php index 0496fa444..8eff9169e 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_extra5.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_extra5.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule1.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule1.php index 27297c832..f21b520c4 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule1.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule1.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule10.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule10.php index 6c5a0c94b..528764c59 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule10.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule10.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule11.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule11.php index eb3b8f4ad..ea0cedc02 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule11.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule11.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule2.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule2.php index 648d24aa3..febcd5f39 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule2.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule2.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule3.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule3.php index 3b3954a17..602226e89 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule3.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule3.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule4.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule4.php index 6e07994f6..ba03f7696 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule4.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule4.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule5.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule5.php index 446120f46..ad9337295 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule5.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule5.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule6.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule6.php index 5544883ff..60bd29813 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule6.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule6.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule7.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule7.php index d4c4f85a6..95f97c449 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule7.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule7.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule8.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule8.php index abf12928f..527c79a7e 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule8.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule8.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_filter_rule9.php b/tests/integration/logging/monolog3/test_monolog_context_filter_rule9.php index 61c8f1a0c..98fc8b5e2 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_filter_rule9.php +++ b/tests/integration/logging/monolog3/test_monolog_context_filter_rule9.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_limits_1.php b/tests/integration/logging/monolog3/test_monolog_context_limits_1.php index 0eb98376f..9d5836311 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_limits_1.php +++ b/tests/integration/logging/monolog3/test_monolog_context_limits_1.php @@ -45,6 +45,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_limits_2.php b/tests/integration/logging/monolog3/test_monolog_context_limits_2.php index 6efed9ff5..6925fc905 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_limits_2.php +++ b/tests/integration/logging/monolog3/test_monolog_context_limits_2.php @@ -45,6 +45,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_precedence_1.php b/tests/integration/logging/monolog3/test_monolog_context_precedence_1.php index 6c66317b6..301164d11 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_precedence_1.php +++ b/tests/integration/logging/monolog3/test_monolog_context_precedence_1.php @@ -48,6 +48,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_precedence_2.php b/tests/integration/logging/monolog3/test_monolog_context_precedence_2.php index 451e5f49b..b05977c22 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_precedence_2.php +++ b/tests/integration/logging/monolog3/test_monolog_context_precedence_2.php @@ -48,6 +48,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_context_simple.php b/tests/integration/logging/monolog3/test_monolog_context_simple.php index 3c6fd51ef..1e77e6d25 100644 --- a/tests/integration/logging/monolog3/test_monolog_context_simple.php +++ b/tests/integration/logging/monolog3/test_monolog_context_simple.php @@ -59,6 +59,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_decoration_and_forwarding.php b/tests/integration/logging/monolog3/test_monolog_decoration_and_forwarding.php index 20b201daa..fa0bbb6cb 100644 --- a/tests/integration/logging/monolog3/test_monolog_decoration_and_forwarding.php +++ b/tests/integration/logging/monolog3/test_monolog_decoration_and_forwarding.php @@ -113,6 +113,7 @@ [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/api/get_linking_metadata"}, [16, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_disable_metrics.php b/tests/integration/logging/monolog3/test_monolog_disable_metrics.php index 90e6767fb..cb5beb8e1 100644 --- a/tests/integration/logging/monolog3/test_monolog_disable_metrics.php +++ b/tests/integration/logging/monolog3/test_monolog_disable_metrics.php @@ -51,6 +51,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_drop_empty.php b/tests/integration/logging/monolog3/test_monolog_drop_empty.php index 4cee51f79..61937fb9f 100644 --- a/tests/integration/logging/monolog3/test_monolog_drop_empty.php +++ b/tests/integration/logging/monolog3/test_monolog_drop_empty.php @@ -57,6 +57,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_escape_chars.php b/tests/integration/logging/monolog3/test_monolog_escape_chars.php index c7978a7a2..a1c768efd 100644 --- a/tests/integration/logging/monolog3/test_monolog_escape_chars.php +++ b/tests/integration/logging/monolog3/test_monolog_escape_chars.php @@ -38,6 +38,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_large_message_limit.php b/tests/integration/logging/monolog3/test_monolog_large_message_limit.php index 1e25b451f..191800f49 100644 --- a/tests/integration/logging/monolog3/test_monolog_large_message_limit.php +++ b/tests/integration/logging/monolog3/test_monolog_large_message_limit.php @@ -40,6 +40,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [833, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_large_message_limit_drops.php b/tests/integration/logging/monolog3/test_monolog_large_message_limit_drops.php index 66de51989..eed9a410a 100644 --- a/tests/integration/logging/monolog3/test_monolog_large_message_limit_drops.php +++ b/tests/integration/logging/monolog3/test_monolog_large_message_limit_drops.php @@ -40,6 +40,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1666, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_limit_log_events.php b/tests/integration/logging/monolog3/test_monolog_limit_log_events.php index 69bdb618c..b1f72e6b6 100644 --- a/tests/integration/logging/monolog3/test_monolog_limit_log_events.php +++ b/tests/integration/logging/monolog3/test_monolog_limit_log_events.php @@ -58,6 +58,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_limit_zero_events.php b/tests/integration/logging/monolog3/test_monolog_limit_zero_events.php index a9dd71587..38abfe890 100644 --- a/tests/integration/logging/monolog3/test_monolog_limit_zero_events.php +++ b/tests/integration/logging/monolog3/test_monolog_limit_zero_events.php @@ -58,6 +58,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid1.php b/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid1.php index 7b5892cc0..f33d832af 100644 --- a/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid1.php +++ b/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid1.php @@ -45,6 +45,7 @@ [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [833, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid2.php b/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid2.php index 644512bc2..73c70e58e 100644 --- a/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid2.php +++ b/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid2.php @@ -45,6 +45,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [833, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid3.php b/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid3.php index d64021bad..72ca4b06b 100644 --- a/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid3.php +++ b/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid3.php @@ -45,6 +45,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [833, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid4.php b/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid4.php index 7879dba27..2f60d6bc1 100644 --- a/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid4.php +++ b/tests/integration/logging/monolog3/test_monolog_log_events_max_samples_stored_invalid4.php @@ -45,6 +45,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [833, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog3/test_monolog_log_level_filter.php b/tests/integration/logging/monolog3/test_monolog_log_level_filter.php index 14a0a0c95..529ef1459 100644 --- a/tests/integration/logging/monolog3/test_monolog_log_level_filter.php +++ b/tests/integration/logging/monolog3/test_monolog_log_level_filter.php @@ -60,6 +60,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog3/test_monolog_log_level_filter_invalid.php b/tests/integration/logging/monolog3/test_monolog_log_level_filter_invalid.php index 5659971f3..e5387616f 100644 --- a/tests/integration/logging/monolog3/test_monolog_log_level_filter_invalid.php +++ b/tests/integration/logging/monolog3/test_monolog_log_level_filter_invalid.php @@ -61,6 +61,7 @@ [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [8, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/logging/monolog3/test_monolog_truncate_long_msgs.php b/tests/integration/logging/monolog3/test_monolog_truncate_long_msgs.php index ac7e15bcf..4c99e09ba 100644 --- a/tests/integration/logging/monolog3/test_monolog_truncate_long_msgs.php +++ b/tests/integration/logging/monolog3/test_monolog_truncate_long_msgs.php @@ -43,6 +43,7 @@ [{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], + [{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], diff --git a/tests/integration/predis/predis.inc b/tests/integration/predis/predis.inc index dbf390605..0788d2fb7 100644 --- a/tests/integration/predis/predis.inc +++ b/tests/integration/predis/predis.inc @@ -4,6 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +if (version_compare(PHP_VERSION, '7.2', '<')) { + die("skip: PHP 7.2+ required\n"); +} + $PREDIS_HOME = getenv("PREDIS_HOME"); if (empty($PREDIS_HOME)) { diff --git a/tests/integration/predis/test_basic.php b/tests/integration/predis/test_basic.php index 0adfeaa04..68abdf928 100644 --- a/tests/integration/predis/test_basic.php +++ b/tests/integration/predis/test_basic.php @@ -54,6 +54,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/predis/predis/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/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 4355fd359..03c84c3bb 100644 --- a/tests/integration/predis/test_basic_logging_off.php +++ b/tests/integration/predis/test_basic_logging_off.php @@ -57,6 +57,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/predis/predis/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/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 b8ad0d057..73d262965 100644 --- a/tests/integration/predis/test_basic_reporting_disabled.php +++ b/tests/integration/predis/test_basic_reporting_disabled.php @@ -59,6 +59,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/predis/predis/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/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 1592084de..32312aab4 100644 --- a/tests/integration/predis/test_pipeline.php +++ b/tests/integration/predis/test_pipeline.php @@ -47,6 +47,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/predis/predis/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/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 620336534..fd695e5ed 100644 --- a/tests/integration/predis/test_pipeline_atomic.php +++ b/tests/integration/predis/test_pipeline_atomic.php @@ -47,6 +47,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/predis/predis/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/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 ef3fdc2c6..4f7225884 100644 --- a/tests/integration/predis/test_pipeline_fire_and_forget.php +++ b/tests/integration/predis/test_pipeline_fire_and_forget.php @@ -47,6 +47,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/predis/predis/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/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 fc15d052c..82a76903e 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 @@ -50,6 +50,7 @@ [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"Supportability/PHP/package/predis/predis/2/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/library/Predis/detected"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Forwarding/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/Metrics/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], From 7c985b8e514f5e1689126db92c1bca6e5f06b83d Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Tue, 23 Apr 2024 09:48:00 -0400 Subject: [PATCH 09/44] feat(agent): update default for wp hooks options (#880) To reduce agent's overhead, by default the agent will only instrument hook callbacks from plugins/themes and will not instrument hook callbacks from wordpress core. --- agent/php_nrini.c | 2 +- agent/scripts/newrelic.ini.template | 14 +++++++------- .../frameworks/wordpress/test_wordpress_00.php | 8 ++++---- .../wordpress/test_wordpress_00.php7.php | 8 ++++---- .../frameworks/wordpress/test_wordpress_00_1.php | 8 ++++---- .../frameworks/wordpress/test_wordpress_00_2.php | 8 ++++---- .../wordpress/test_wordpress_apply_filters.php | 6 +++--- .../wordpress/test_wordpress_do_action.php | 7 +++---- .../test_wordpress_transaction_name_hooks_on.php | 8 +++----- 9 files changed, 33 insertions(+), 36 deletions(-) diff --git a/agent/php_nrini.c b/agent/php_nrini.c index 1a5d5c831..2ed62eb10 100644 --- a/agent/php_nrini.c +++ b/agent/php_nrini.c @@ -1896,7 +1896,7 @@ static PHP_INI_MH(nr_custom_events_max_samples_stored_mh) { return SUCCESS; } -#define DEFAULT_WORDPRESS_HOOKS_OPTIONS "all_callbacks" +#define DEFAULT_WORDPRESS_HOOKS_OPTIONS "plugin_callbacks" static PHP_INI_MH(nr_wordpress_hooks_options_mh) { nrinistr_t* p; diff --git a/agent/scripts/newrelic.ini.template b/agent/scripts/newrelic.ini.template index eb0d24b00..0e5da6ab3 100644 --- a/agent/scripts/newrelic.ini.template +++ b/agent/scripts/newrelic.ini.template @@ -1169,17 +1169,17 @@ newrelic.daemon.logfile = "/var/log/newrelic/newrelic-daemon.log" ; Setting: newrelic.framework.wordpress.hooks.options ; Type : string (all_callbacks, plugin_callbacks, threshold) ; Scope : per-directory -; Default: all_callbacks +; Default: plugin_callbacks ; Info : Sets the options how WordPress hooks are instrumented. ; ; New Relic agent can provide different levels of insights into WordPress hooks. -; By default, all hook callbacks functions are instrumented ("all_callbacks"). -; To reduce agent's overhead it is possible to limit the instrumentation to only -; plugin/theme callbacks ("plugin_callbacks"). Third option is to monitor hooks -; without instrumenting callbacks ("threshold"). This option does not give insights -; about plugins/themes. +; By default, only plugin/theme callbacks are instrumented ("plugin_callbacks"). +; At the cost of increased agent's overhead it is possible to extend the +; instrumentation to all hook callbacks functions ("all_callbacks"). Third option +; is to monitor hooks without instrumenting callbacks ("threshold"). This option +; does not give insights about plugins/themes. ; -;newrelic.framework.wordpress.hooks.options = "all_callbacks" +;newrelic.framework.wordpress.hooks.options = "plugin_callbacks" ; Setting: newrelic.framework.wordpress.hooks.threshold ; Type : time specification string ("500ms", "1s750ms" etc) diff --git a/tests/integration/frameworks/wordpress/test_wordpress_00.php b/tests/integration/frameworks/wordpress/test_wordpress_00.php index 946e497ba..46451d5b7 100644 --- a/tests/integration/frameworks/wordpress/test_wordpress_00.php +++ b/tests/integration/frameworks/wordpress/test_wordpress_00.php @@ -9,8 +9,8 @@ - detect WordPress framework - name the web transaction as an 'Action' named after the template used to generate the page - detect custom plugins and themes - - generate hooks metrics for all callback functions executions; the execution time of callback - functions from wordpress core, custom plugins and themes is captured. + - generate hooks metrics only for plugins and themes callback functions executions; + only the execution time of callback functions from custom plugins and themes is captured. No errors should be generated. */ @@ -40,11 +40,11 @@ functions from wordpress core, custom plugins and themes is captured. Framework/WordPress/Plugin/mock-plugin2 Framework/WordPress/Plugin/mock-theme1 Framework/WordPress/Plugin/mock-theme2 -Framework/WordPress/Hook/wp_init -Framework/WordPress/Hook/the_content */ /*EXPECT_METRICS_DONT_EXIST +Framework/WordPress/Hook/wp_init +Framework/WordPress/Hook/the_content */ /*EXPECT_ERROR_EVENTS null */ diff --git a/tests/integration/frameworks/wordpress/test_wordpress_00.php7.php b/tests/integration/frameworks/wordpress/test_wordpress_00.php7.php index fa2cfa826..adc5d1970 100644 --- a/tests/integration/frameworks/wordpress/test_wordpress_00.php7.php +++ b/tests/integration/frameworks/wordpress/test_wordpress_00.php7.php @@ -9,8 +9,8 @@ - detect WordPress framework - name the web transaction as an 'Action' named after the template used to generate the page - detect custom plugins and themes - - generate hooks metrics for all callback functions executions; the execution time of callback - functions from wordpress core, custom plugins and themes is captured. + - generate hooks metrics only for plugins and themes callback functions executions; + only the execution time of callback functions from custom plugins and themes is captured. No errors should be generated. */ @@ -32,11 +32,11 @@ functions from wordpress core, custom plugins and themes is captured. Framework/WordPress/Plugin/mock-plugin2 Framework/WordPress/Plugin/mock-theme1 Framework/WordPress/Plugin/mock-theme2 -Framework/WordPress/Hook/wp_init -Framework/WordPress/Hook/the_content */ /*EXPECT_METRICS_DONT_EXIST +Framework/WordPress/Hook/wp_init +Framework/WordPress/Hook/the_content */ /*EXPECT_ERROR_EVENTS null */ diff --git a/tests/integration/frameworks/wordpress/test_wordpress_00_1.php b/tests/integration/frameworks/wordpress/test_wordpress_00_1.php index c12a731de..8823a86e9 100644 --- a/tests/integration/frameworks/wordpress/test_wordpress_00_1.php +++ b/tests/integration/frameworks/wordpress/test_wordpress_00_1.php @@ -10,8 +10,8 @@ - detect WordPress framework - name the web transaction as an 'Action' named after the template used to generate the page - detect custom plugins and themes - - generate hooks metrics for all callback functions executions; the execution time of callback - functions from wordpress core, custom plugins and themes is captured. + - generate hooks metrics only for plugins and themes callback functions executions; + only the execution time of callback functions from custom plugins and themes is captured. No errors should be generated. */ @@ -34,11 +34,11 @@ functions from wordpress core, custom plugins and themes is captured. Framework/WordPress/Plugin/mock-plugin2 Framework/WordPress/Plugin/mock-theme1 Framework/WordPress/Plugin/mock-theme2 -Framework/WordPress/Hook/wp_init -Framework/WordPress/Hook/the_content */ /*EXPECT_METRICS_DONT_EXIST +Framework/WordPress/Hook/wp_init +Framework/WordPress/Hook/the_content */ /*EXPECT_ERROR_EVENTS null */ diff --git a/tests/integration/frameworks/wordpress/test_wordpress_00_2.php b/tests/integration/frameworks/wordpress/test_wordpress_00_2.php index 3dc12e750..e7ec3b8d3 100644 --- a/tests/integration/frameworks/wordpress/test_wordpress_00_2.php +++ b/tests/integration/frameworks/wordpress/test_wordpress_00_2.php @@ -10,8 +10,8 @@ - detect WordPress framework - name the web transaction as an 'Action' named after the template used to generate the page - detect custom plugins and themes - - generate hooks metrics for all callback functions executions; the execution time of callback - functions from wordpress core, custom plugins and themes is captured. + - generate hooks metrics only for plugins and themes callback functions executions; + only the execution time of callback functions from custom plugins and themes is captured. No errors should be generated. */ @@ -34,11 +34,11 @@ functions from wordpress core, custom plugins and themes is captured. Framework/WordPress/Plugin/mock-plugin2 Framework/WordPress/Plugin/mock-theme1 Framework/WordPress/Plugin/mock-theme2 -Framework/WordPress/Hook/wp_init -Framework/WordPress/Hook/the_content */ /*EXPECT_METRICS_DONT_EXIST +Framework/WordPress/Hook/wp_init +Framework/WordPress/Hook/the_content */ /*EXPECT_ERROR_EVENTS null */ diff --git a/tests/integration/frameworks/wordpress/test_wordpress_apply_filters.php b/tests/integration/frameworks/wordpress/test_wordpress_apply_filters.php index 9c2f84fa1..062f6d4e6 100644 --- a/tests/integration/frameworks/wordpress/test_wordpress_apply_filters.php +++ b/tests/integration/frameworks/wordpress/test_wordpress_apply_filters.php @@ -8,8 +8,8 @@ The agent should properly instrument Wordpress apply_filters hooks. Since the mocked hooks are detected by the agent as WordPress core (plugin_from_function returns NULL), and WordPress core callbacks are not instrumented by default, -therefore newrelic.framework.wordpress.core needs to be set to true for the -agent to generate the hooks metrics. +therefore newrelic.framework.wordpress.hooks.options needs to be set to +"all_callbacks" for the agent to generate the hooks metrics. */ /*SKIPIF @@ -18,7 +18,7 @@ /*INI newrelic.framework = wordpress newrelic.framework.wordpress.hooks_threshold = 0 -newrelic.framework.wordpress.core = true +newrelic.framework.wordpress.hooks.options = all_callbacks */ /*EXPECT diff --git a/tests/integration/frameworks/wordpress/test_wordpress_do_action.php b/tests/integration/frameworks/wordpress/test_wordpress_do_action.php index cf3b1b50b..cad1bf607 100644 --- a/tests/integration/frameworks/wordpress/test_wordpress_do_action.php +++ b/tests/integration/frameworks/wordpress/test_wordpress_do_action.php @@ -8,8 +8,8 @@ The agent should properly instrument Wordpress do_action hooks. Since the mocked hooks are detected by the agent as WordPress core (plugin_from_function returns NULL), and WordPress core callbacks are not instrumented by default, -therefore newrelic.framework.wordpress.core needs to be set to true for the -agent to generate the hooks metrics. +therefore newrelic.framework.wordpress.hooks.options needs to be set to +"all_callbacks" for the agent to generate the hooks metrics. */ /*SKIPIF @@ -17,8 +17,7 @@ /*INI newrelic.framework = wordpress -newrelic.framework.wordpress.hooks_threshold = 0 -newrelic.framework.wordpress.core = true +newrelic.framework.wordpress.hooks.options = all_callbacks */ /*EXPECT diff --git a/tests/integration/frameworks/wordpress/test_wordpress_transaction_name_hooks_on.php b/tests/integration/frameworks/wordpress/test_wordpress_transaction_name_hooks_on.php index 9ad96a5f7..71abe758f 100644 --- a/tests/integration/frameworks/wordpress/test_wordpress_transaction_name_hooks_on.php +++ b/tests/integration/frameworks/wordpress/test_wordpress_transaction_name_hooks_on.php @@ -11,17 +11,15 @@ metric should be generated and the hook function should be instrumented. However, since the mocked hooks are detected by the agent as WordPress core (plugin_from_function returns NULL), and WordPress core callbacks are not -instrumented by default, therefore newrelic.framework.wordpress.core needs -to be set to true for the agent to generate the hooks metrics. +instrumented by default, therefore therefore newrelic.framework.wordpress.hooks.options +needs to be set to "all_callbacks" for the agent to generate the hooks metrics. */ /*SKIPIF*/ /*INI newrelic.framework = wordpress -newrelic.framework.wordpress.hooks = true -newrelic.framework.wordpress.hooks_threshold = 0 -newrelic.framework.wordpress.core = true +newrelic.framework.wordpress.hooks.options = all_callbacks */ /*ENVIRONMENT From ac8271c0130b2d0a3c7f26e14d22ef495e5ee71c Mon Sep 17 00:00:00 2001 From: Michael Fulbright <89205663+mfulb@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:31:32 -0400 Subject: [PATCH 10/44] fix(agent): Fixes warning from mysqli when explaining slow SQL queries (GH issue 875) (#881) In GH issue #875 it was reported a warning is generated when using prepared statements with `mysqli`. The issue included excellent instructions on how to reproduce the issue. This PR addresses the cause of the warning. To understand the cause of the warning requires understanding how the agent handles `mysqli::stmt` objects. When a SQL statement is prepared via mysqli the agent will store the SQL string in a global hashmap called `mysqli_queries` *if* the SQL is considered explainable (determined via `nr_php_explain_mysql_query_is_explainable()`), otherwise it is just ignored. Later when a slow SQL query is detected the SQL string is retrieved and used to explain the query. An additional factor is when a `mysqli::stmt` object is released it goes into a free pool PHP keeps which allows it to quickly hand out an allocated section of memory when a new object is created. Each object has a `object ID` (referenced as a `handle` in the agent for the relevant code). When an the allocated object is reused from the free pool it retains the same `object ID`. The agent used the `object ID` (`handle`) as the key for storing the prepared SQL string for explainable SQL strings. Now what if an explainable query comes through, the string is stored, and then that object is released. A new query is prepared with a string that is NOT explainable and gets the object container with the same `object ID` as the explainable one just released. The string stored in `mysqli_queries` using that `object ID` as the key is now stale. If the new, unexplainable query is slow then the agent will pull this stale string and try to run an explain with it - leading to the warning. The fix is to clear any query string for a given `object ID` if the query string is unexplainable. Integration tests were added (based on the reproduction case) that test for a regression of this fix. --- agent/php_internal_instrument.c | 23 ++- agent/php_mysqli.c | 25 +++ agent/php_mysqli.h | 9 + .../test_explain_reused_id_multiple_001.php | 124 ++++++++++++ .../test_explain_reused_id_multiple_002.php | 176 ++++++++++++++++++ 5 files changed, 350 insertions(+), 7 deletions(-) create mode 100644 tests/integration/mysqli/test_explain_reused_id_multiple_001.php create mode 100644 tests/integration/mysqli/test_explain_reused_id_multiple_002.php diff --git a/agent/php_internal_instrument.c b/agent/php_internal_instrument.c index 15c43dcdd..821379edb 100644 --- a/agent/php_internal_instrument.c +++ b/agent/php_internal_instrument.c @@ -1358,15 +1358,24 @@ static void nr_php_prepared_prepare_general(INTERNAL_FUNCTION_PARAMETERS, nr_php_prepared_statement_save(return_value, extension, sqlstr, sqlstrlen TSRMLS_CC); + /* Record the current query link and SQL string if the right conditions exist + * Note if the SQL string is not explainable then the previous recorded query + * string (from the query previously using the same handle) needs to be + * cleared so that the previous string is not errantly retrieved and "EXPLAIN" + * run with it + */ + if ((0 == NRTXNGLOBAL(generating_explain_plan)) - && nr_php_mysqli_zval_is_stmt(return_value TSRMLS_CC) - && nr_php_mysqli_zval_is_link(conn_obj TSRMLS_CC) - && nr_php_explain_mysql_query_is_explainable(sqlstr, sqlstrlen)) { - nr_php_mysqli_query_set_link(Z_OBJ_HANDLE_P(return_value), - conn_obj TSRMLS_CC); + && nr_php_mysqli_zval_is_stmt(return_value) + && nr_php_mysqli_zval_is_link(conn_obj)) { + nr_php_mysqli_query_set_link(Z_OBJ_HANDLE_P(return_value), conn_obj); - nr_php_mysqli_query_set_query(Z_OBJ_HANDLE_P(return_value), sqlstr, - sqlstrlen TSRMLS_CC); + if (nr_php_explain_mysql_query_is_explainable(sqlstr, sqlstrlen)) { + nr_php_mysqli_query_set_query(Z_OBJ_HANDLE_P(return_value), sqlstr, + sqlstrlen); + } else { + nr_php_mysqli_query_clear_query(Z_OBJ_HANDLE_P(return_value)); + } } } diff --git a/agent/php_mysqli.c b/agent/php_mysqli.c index f818fdba4..b17fd2491 100644 --- a/agent/php_mysqli.c +++ b/agent/php_mysqli.c @@ -353,6 +353,31 @@ nr_status_t nr_php_mysqli_query_set_query(nr_php_object_handle_t handle, return NR_SUCCESS; } +nr_status_t nr_php_mysqli_query_clear_query(nr_php_object_handle_t handle) { + zval* metadata = NULL; + + /* If a metadata entry exists then clear the "query" tag from it. + * If an entry does not exist then nothing needs to be done. + */ + metadata = nr_php_mysqli_query_find(handle); + if (NULL == metadata) { + return NR_FAILURE; + } + + /* Clear the "query" element */ + nr_php_zend_hash_del(Z_ARRVAL_P(metadata), "query"); + + /* + * Since the query is cleared so must the bind parameters, so let's get rid of + * whatever's here. We'll ignore the return values, since if the keys don't + * already exist no harm is done. + */ + nr_php_zend_hash_del(Z_ARRVAL_P(metadata), "bind_args"); + nr_php_zend_hash_del(Z_ARRVAL_P(metadata), "bind_format"); + + return NR_SUCCESS; +} + int nr_php_mysqli_zval_is_link(const zval* zv TSRMLS_DC) { if (NULL == zv) { return 0; diff --git a/agent/php_mysqli.h b/agent/php_mysqli.h index ca4568ea5..03d42cf57 100644 --- a/agent/php_mysqli.h +++ b/agent/php_mysqli.h @@ -87,6 +87,15 @@ extern nr_status_t nr_php_mysqli_query_set_link( nr_php_object_handle_t query_handle, zval* link TSRMLS_DC); +/* + * Purpose : Clear the SQL used to prepare a MySQLi statement. + * + * Params : 1. The object handle of the statement. + * + * Returns : NR_SUCCESS or NR_FAILURE. + */ +extern nr_status_t nr_php_mysqli_query_clear_query(nr_php_object_handle_t handle); + /* * Purpose : Save the SQL used to prepare a MySQLi statement. * diff --git a/tests/integration/mysqli/test_explain_reused_id_multiple_001.php b/tests/integration/mysqli/test_explain_reused_id_multiple_001.php new file mode 100644 index 000000000..815472ad6 --- /dev/null +++ b/tests/integration/mysqli/test_explain_reused_id_multiple_001.php @@ -0,0 +1,124 @@ +prepare("SELECT ?"); +} + +/* Run an SQL query. + Params: + $dbConn mysql connection object + $delay delay for query in seconds + $explainable true if query is explainable, otherwise an + unexplainable sql query is run +*/ +function doSQL($dbConn, $delay, $explainable) { + + /* if sql statement has 2 ';' then agent considers it as multi-statement + and treats it as unexplainable, see nr_php_explain_mysql_query_is_explainable() + */ + if ($explainable) { + $suffix = ""; + } else { + $suffix = ";;"; + } + + $stmt = $dbConn->prepare("SELECT TABLE_NAME FROM information_schema.tables WHERE table_name=? AND SLEEP(?)" . $suffix); + + if (! $stmt) { + throw new Exception("Prepare Failed : " . $dbConn->error); + } + + $table = "STATISTICS"; + $stmt->bind_param('si', $table, $delay); + if (! $stmt->execute()) { + throw new Exception("Execute Failed : " . $stmt->error); + } + + $stmt->bind_result($someId); + $stmt->fetch(); + $stmt->close(); +} + +/* main code */ +require_once(realpath (dirname ( __FILE__ )) . '/../../include/config.php'); + +$dbConn = new mysqli($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWD, $MYSQL_DB, $MYSQL_PORT, $MYSQL_SOCKET); + +/* run a test where a prepared, explainable statement is prepared + but not executed. Then run a prepared, unexplainable slow sql + query which should not be explained. This will lead to the + first stmt object being reused for the second slow sql query. + + Tests for reqgression of a bug where the query string + from a previous, explainable SQL query with the same object ID + ("handle") would be used in error. +*/ + +justPrepare($dbConn); +doSQL($dbConn, 1, false); + +echo "If you see this message, it didn't crash\n"; + diff --git a/tests/integration/mysqli/test_explain_reused_id_multiple_002.php b/tests/integration/mysqli/test_explain_reused_id_multiple_002.php new file mode 100644 index 000000000..6e79daf11 --- /dev/null +++ b/tests/integration/mysqli/test_explain_reused_id_multiple_002.php @@ -0,0 +1,176 @@ +prepare("SELECT ?"); +} + +/* Run an SQL query. + Params: + $dbConn mysql connection object + $delay delay for query in seconds + $explainable true if query is explainable, otherwise an + unexplainable sql query is run +*/ +function doSQL($dbConn, $delay, $explainable) { + + /* if sql statement has 2 ';' then agent considers it as multi-statement + and treats it as unexplainable, see nr_php_explain_mysql_query_is_explainable() + */ + if ($explainable) { + $suffix = ""; + } else { + $suffix = ";;"; + } + + $stmt = $dbConn->prepare("SELECT TABLE_NAME FROM information_schema.tables WHERE table_name=? AND SLEEP(?)" . $suffix); + + if (! $stmt) { + throw new Exception("Prepare Failed : " . $dbConn->error); + } + + $table = "STATISTICS"; + $stmt->bind_param('si', $table, $delay); + if (! $stmt->execute()) { + throw new Exception("Execute Failed : " . $stmt->error); + } + + $stmt->bind_result($someId); + $stmt->fetch(); + $stmt->close(); +} + + + +/* main code */ +require_once(realpath (dirname ( __FILE__ )) . '/../../include/config.php'); + +$dbConn = new mysqli($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWD, $MYSQL_DB, $MYSQL_PORT, $MYSQL_SOCKET); + +/* run a test where a prepared, explainable statement is prepared + but not executed. Then run a prepared, unexplainable slow sql + query which should not be explained. This will lead to the + first stmt object being reused for the second slow sql query. + Then run an explainable, slow SQL query and confirm it is + explained. + + Tests for reqgression of a bug where the query string + from a previous, explainable SQL query with the same object ID + ("handle") would be used in error. +*/ + +justPrepare($dbConn); +doSQL($dbConn, 1, false); +doSQL($dbConn, 1, true); + +echo "If you see this message, it didn't crash\n"; + From 732ebb8aa2c3526c505d99a7117ae35165a58fb5 Mon Sep 17 00:00:00 2001 From: Michael Fulbright <89205663+mfulb@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:04:08 -0400 Subject: [PATCH 11/44] fix(tests): Fixes mysqli test by adding missing slowsql (#882) A EXPECT_SLOW_SQLS specification was left out of one test from PR #881 . --- .../integration/mysqli/test_explain_reused_id_multiple_001.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integration/mysqli/test_explain_reused_id_multiple_001.php b/tests/integration/mysqli/test_explain_reused_id_multiple_001.php index 815472ad6..e5a91d21d 100644 --- a/tests/integration/mysqli/test_explain_reused_id_multiple_001.php +++ b/tests/integration/mysqli/test_explain_reused_id_multiple_001.php @@ -25,8 +25,7 @@ newrelic.transaction_tracer.record_sql = obfuscated */ -/* - +/*EXPECT_SLOW_SQLS [ [ [ From 9ce7264c85bcf691d73ed3822693ee215085468c Mon Sep 17 00:00:00 2001 From: bduranleau-nr <106178551+bduranleau-nr@users.noreply.github.com> Date: Fri, 26 Apr 2024 09:16:29 -0500 Subject: [PATCH 12/44] ci: add gh issue response automation workflow (#867) Adds a workflow to enable automated responses via the newrelic-php-agent-bot to newly opened GitHub issues as well as issues determined to require additional support engagement. --------- Co-authored-by: Amber Sistla Co-authored-by: Hitesh Ahuja <108540135+hahuja2@users.noreply.github.com> Co-authored-by: Michal Nowacki Co-authored-by: Hitesh Ahuja --- .github/workflows/bug-report-response.yml | 36 +++++++++++++++++++++++ .github/workflows/issue-comment.yml | 25 ++++++++++++++++ .github/workflows/issue-support-label.yml | 28 ++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 .github/workflows/bug-report-response.yml create mode 100644 .github/workflows/issue-comment.yml create mode 100644 .github/workflows/issue-support-label.yml diff --git a/.github/workflows/bug-report-response.yml b/.github/workflows/bug-report-response.yml new file mode 100644 index 000000000..e7cb9aeef --- /dev/null +++ b/.github/workflows/bug-report-response.yml @@ -0,0 +1,36 @@ +# Copyright 2020 New Relic Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# + +name: bug-report-response + +on: + issues: + types: + - labeled + +jobs: + bug-report-response: + if: github.event.label.name == 'bug' && github.event.issue.state == 'open' + uses: ./.github/workflows/issue-comment.yml + with: + issue-number: ${{ github.event.issue.number }} + message: > + Thank you for your issue report. A member of the New Relic PHP Agent Team + will review your report and endeavor to respond in a timely manner. + + Need troubleshooting help? Please review some of our common troubleshooting documentation, starting with [generating debug logs](https://docs.newrelic.com/docs/apm/agents/php-agent/troubleshooting/generating-logs-troubleshooting-php/). + From there, additional resources and tips are available in our troubleshooting section, accessible from the left-hand panel of our documentation site. Additionally, please be sure to visit + our [Explorer's Hub](https://forum.newrelic.com/s/), where other members of the community may have solved an issue similar to yours with the help of our Support team members. + + Have a question regarding support for an Operating System, PHP Version, Framework, or Library? + Please take a look at our [Compatibility Docs](https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/php-agent-compatibility-requirements/). + + Binary support for ARM-based CPU architecture is now available via the [tarball installation](https://docs.newrelic.com/docs/apm/agents/php-agent/installation/php-agent-installation-arm64/#tarball-installation) method for PHP Versions 8.0+! + + General installation instructions can be found on our [Installation Overview](https://docs.newrelic.com/docs/apm/agents/php-agent/installation/php-agent-installation-overview/) page. + + Need more information about an Agent INI setting? Our [Configuration](https://docs.newrelic.com/docs/apm/agents/php-agent/configuration/php-agent-configuration/) + page contains an explanation for each INI setting and how to modify the defaults. + + Looking for something else? All New Relic PHP Agent Documentation can be found under our [Introduction](https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/introduction-new-relic-php/) page. diff --git a/.github/workflows/issue-comment.yml b/.github/workflows/issue-comment.yml new file mode 100644 index 000000000..377d711e3 --- /dev/null +++ b/.github/workflows/issue-comment.yml @@ -0,0 +1,25 @@ +# Copyright 2020 New Relic Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# + +name: issue-comment + +on: + workflow_call: + inputs: + issue-number: + type: number + required: true + message: + type: string + required: true + +jobs: + post-comment: + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.ISSUE_BOT_TOKEN }} + steps: + - name: respond to issue + run: | + gh issue comment ${{ inputs.issue-number }} --body ${{ inputs.message }} diff --git a/.github/workflows/issue-support-label.yml b/.github/workflows/issue-support-label.yml new file mode 100644 index 000000000..a738068c6 --- /dev/null +++ b/.github/workflows/issue-support-label.yml @@ -0,0 +1,28 @@ +# Copyright 2020 New Relic Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# + +name: issue-support-label + +on: + issues: + types: + - labeled + +jobs: + support-response: + if: github.event.label.name == 'support' && github.event.issue.state == 'open' + uses: ./.github/workflows/issue-comment.yml + with: + issue-number: ${{ github.event.issue.number }} + message: > + This issue has been identified as requiring additional information to debug. + Due to the potentially sensitive nature of the information we may have to collect, + such as PHPInfo and Debug Logs, please follow [these steps](https://docs.newrelic.com/docs/new-relic-solutions/solve-common-issues/find-help-use-support-portal/#file-ticket) + to create a support case, where a member of our New Relic Support Team will work + with you to gather the necessary information securely and help debug your issue. + + If your subscription level does not include technical support, the + other option available to customers is to use New Relic’s community support channel: [Explorers Hub](https://forum.newrelic.com/s/). From there, a member of our New Relic Support Team will work + with you to gather the necessary information securely and help debug your issue. + For all available options on how to get support, please see [these resources](https://docs.newrelic.com/docs/new-relic-solutions/solve-common-issues/find-help-use-support-portal/). From bdbdb662cbfc644fcb306c199c6701b41348bf38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:01:36 +0000 Subject: [PATCH 13/44] chore(deps): bump google.golang.org/protobuf from 1.32.0 to 1.33.0 in /daemon (#855) --- daemon/go.mod | 2 +- daemon/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/go.mod b/daemon/go.mod index 35fc8e742..fba027901 100644 --- a/daemon/go.mod +++ b/daemon/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/flatbuffers v23.5.26+incompatible golang.org/x/net v0.20.0 google.golang.org/grpc v1.61.0 - google.golang.org/protobuf v1.32.0 + google.golang.org/protobuf v1.33.0 ) require ( diff --git a/daemon/go.sum b/daemon/go.sum index 1cbd55602..5d8b00d05 100644 --- a/daemon/go.sum +++ b/daemon/go.sum @@ -19,5 +19,5 @@ google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= From 85d74db73459a561142c8c911d3775b9dadbb809 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:02:39 +0000 Subject: [PATCH 14/44] chore(deps): bump golang.org/x/net from 0.20.0 to 0.23.0 in /daemon (#879) --- daemon/go.mod | 4 ++-- daemon/go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/daemon/go.mod b/daemon/go.mod index fba027901..06d57f2a1 100644 --- a/daemon/go.mod +++ b/daemon/go.mod @@ -5,13 +5,13 @@ go 1.21.1 require ( github.com/golang/protobuf v1.5.3 github.com/google/flatbuffers v23.5.26+incompatible - golang.org/x/net v0.20.0 + golang.org/x/net v0.23.0 google.golang.org/grpc v1.61.0 google.golang.org/protobuf v1.33.0 ) require ( - golang.org/x/sys v0.16.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect ) diff --git a/daemon/go.sum b/daemon/go.sum index 5d8b00d05..f7f322d87 100644 --- a/daemon/go.sum +++ b/daemon/go.sum @@ -6,10 +6,10 @@ github.com/google/flatbuffers v23.5.26+incompatible/go.mod h1:1AeVuKshWv4vARoZat github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 2f024e55b3fd8c983e13219824dc596051dca655 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Mon, 6 May 2024 12:20:48 -0400 Subject: [PATCH 15/44] chore: bump version for next release (#888) --- VERSION | 2 +- axiom/nr_version.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index ea4ccb283..b61c07ffd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.20.0 +10.21.0 diff --git a/axiom/nr_version.c b/axiom/nr_version.c index 9cab7b786..18d948754 100644 --- a/axiom/nr_version.c +++ b/axiom/nr_version.c @@ -23,7 +23,6 @@ /* * Current version naming scheme is flowers * - * allium 14Mar2022 (9.20) * buttercup 26Apr2022 (9.21) * cosmos 29Jun2022 (10.0) * dahlia 19Sep2022 (10.1) @@ -45,8 +44,9 @@ * tulip 21Feb2024 (10.17) * ulmus 04Mar2024 (10.18) * viburnum 18Mar2024 (10.19) + * wallflower 06May2024 (10.20) */ -#define NR_CODENAME "wallflower" +#define NR_CODENAME "xerophyllum" const char* nr_version(void) { return NR_STR2(NR_VERSION); From 692e41e58ac88907507c383c5eac55fb49afdd17 Mon Sep 17 00:00:00 2001 From: bduranleau-nr <106178551+bduranleau-nr@users.noreply.github.com> Date: Tue, 7 May 2024 14:31:57 -0500 Subject: [PATCH 16/44] ci: fix body handling for issue response (#889) --- .github/workflows/bug-report-response.yml | 2 +- .github/workflows/issue-comment.yml | 2 +- .github/workflows/issue-support-label.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bug-report-response.yml b/.github/workflows/bug-report-response.yml index e7cb9aeef..e37ec5b65 100644 --- a/.github/workflows/bug-report-response.yml +++ b/.github/workflows/bug-report-response.yml @@ -18,7 +18,7 @@ jobs: message: > Thank you for your issue report. A member of the New Relic PHP Agent Team will review your report and endeavor to respond in a timely manner. - + Need troubleshooting help? Please review some of our common troubleshooting documentation, starting with [generating debug logs](https://docs.newrelic.com/docs/apm/agents/php-agent/troubleshooting/generating-logs-troubleshooting-php/). From there, additional resources and tips are available in our troubleshooting section, accessible from the left-hand panel of our documentation site. Additionally, please be sure to visit our [Explorer's Hub](https://forum.newrelic.com/s/), where other members of the community may have solved an issue similar to yours with the help of our Support team members. diff --git a/.github/workflows/issue-comment.yml b/.github/workflows/issue-comment.yml index 377d711e3..b0a79f35e 100644 --- a/.github/workflows/issue-comment.yml +++ b/.github/workflows/issue-comment.yml @@ -22,4 +22,4 @@ jobs: steps: - name: respond to issue run: | - gh issue comment ${{ inputs.issue-number }} --body ${{ inputs.message }} + gh issue comment ${{ inputs.issue-number }} --body "${{ inputs.message }}" diff --git a/.github/workflows/issue-support-label.yml b/.github/workflows/issue-support-label.yml index a738068c6..5f19de221 100644 --- a/.github/workflows/issue-support-label.yml +++ b/.github/workflows/issue-support-label.yml @@ -21,7 +21,7 @@ jobs: such as PHPInfo and Debug Logs, please follow [these steps](https://docs.newrelic.com/docs/new-relic-solutions/solve-common-issues/find-help-use-support-portal/#file-ticket) to create a support case, where a member of our New Relic Support Team will work with you to gather the necessary information securely and help debug your issue. - + If your subscription level does not include technical support, the other option available to customers is to use New Relic’s community support channel: [Explorers Hub](https://forum.newrelic.com/s/). From there, a member of our New Relic Support Team will work with you to gather the necessary information securely and help debug your issue. From 4d729291f7019c7248a26cc72535808fa3dc685d Mon Sep 17 00:00:00 2001 From: Hitesh Ahuja <108540135+hahuja2@users.noreply.github.com> Date: Wed, 8 May 2024 14:35:51 -0700 Subject: [PATCH 17/44] ci: update actions/upload-artifact and actions/download-artifact to v4 (#887) This PR updates `actions/upload-artifact` and `actions/download-artifact` to v4 which uses Node 20: actions/upload-artifact@v3 -> v4: https://github.com/actions/upload-artifact/releases/tag/v4.0.0 actions/download-artifact@v3 -> v4: https://github.com/actions/download-artifact/releases/tag/v4.0.0 --- .github/workflows/code-coverage-baseline.yml | 16 ++++++++-------- .github/workflows/make-agent.yml | 2 +- .github/workflows/make-for-platform-on-arch.yml | 2 +- .github/workflows/make-integration-tests.yml | 4 ++-- .github/workflows/release-build.yml | 8 ++++---- .github/workflows/test-agent.yml | 16 ++++++++-------- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/code-coverage-baseline.yml b/.github/workflows/code-coverage-baseline.yml index fa4052e35..dcef64963 100644 --- a/.github/workflows/code-coverage-baseline.yml +++ b/.github/workflows/code-coverage-baseline.yml @@ -55,7 +55,7 @@ jobs: -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" $IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION daemon_test - name: Save integration_runner for integration tests - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: integration_runner-${{matrix.platform}}-${{matrix.arch}} path: php-agent/bin/integration_runner @@ -124,19 +124,19 @@ jobs: -e ENABLE_COVERAGE=${{matrix.codecov}} $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent-check - name: Save newrelic.so for integration tests - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: newrelic.so-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/agent/modules/newrelic.so - name: Save axiom gcov data files (*.gcno, *.gcna) if: ${{ matrix.codecov == 1 }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: axiom.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/axiom/*.gc* - name: Save agent gcov data files (*.gcno, *.gcna) if: ${{ matrix.codecov == 1 }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: agent.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/agent/.libs/*.gc* @@ -161,24 +161,24 @@ jobs: repository: ${{ inputs.origin }}/newrelic-php-agent ref: ${{ inputs.ref }} - name: Get integration_runner - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: integration_runner-${{matrix.platform}}-${{matrix.arch}} path: php-agent/bin - name: Get newrelic.so - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: newrelic.so-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/agent/modules - name: Get axiom gcov data files if: ${{ matrix.codecov == 1 }} - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: axiom.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/axiom - name: Get agent gcov data files if: ${{ matrix.codecov == 1 }} - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: agent.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/agent/.libs diff --git a/.github/workflows/make-agent.yml b/.github/workflows/make-agent.yml index 87a473159..b29881676 100644 --- a/.github/workflows/make-agent.yml +++ b/.github/workflows/make-agent.yml @@ -62,7 +62,7 @@ jobs: -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent - name: Save newrelic.so for integration tests - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: newrelic.so-${{matrix.platform}}-${{inputs.arch}}-${{matrix.php}} path: php-agent/agent/modules/newrelic.so diff --git a/.github/workflows/make-for-platform-on-arch.yml b/.github/workflows/make-for-platform-on-arch.yml index 053d833ff..17f1d544e 100644 --- a/.github/workflows/make-for-platform-on-arch.yml +++ b/.github/workflows/make-for-platform-on-arch.yml @@ -78,7 +78,7 @@ jobs: -e APP_supportability=${{secrets.APP_SUPPORTABILITY}} $IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION ${{inputs.make-target}} - name: Save ${{inputs.make-target}} artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{inputs.artifact-name}}-${{matrix.platform}}-${{inputs.arch}} path: php-agent/${{ inputs.artifact-pattern }} diff --git a/.github/workflows/make-integration-tests.yml b/.github/workflows/make-integration-tests.yml index 9e08e0b5e..800146f41 100644 --- a/.github/workflows/make-integration-tests.yml +++ b/.github/workflows/make-integration-tests.yml @@ -43,12 +43,12 @@ jobs: repository: ${{ inputs.origin }}/newrelic-php-agent ref: ${{ inputs.ref }} - name: Get integration_runner - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: integration_runner-${{matrix.platform}}-${{inputs.arch}} path: php-agent/bin - name: Get newrelic.so - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: newrelic.so-${{matrix.platform}}-${{inputs.arch}}-${{matrix.php}} path: php-agent/agent/modules diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index b90fc891a..84b74a107 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -52,10 +52,10 @@ jobs: -e BUILD_NUMBER=${{inputs.build-number}} $IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION release-daemon - name: Save build artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: newrelic-php-agent/releases - name: release-from-gha + name: release-from-gha-${{ matrix.platform }}-${{ matrix.arch }} if-no-files-found: error agent_release: env: @@ -87,8 +87,8 @@ jobs: -e BUILD_NUMBER=${{inputs.build-number}} $IMAGE_NAME:agent-builder-php${{matrix.php_ver}}-${{matrix.platform}}-$IMAGE_VERSION release-${{matrix.php_ver}}-gha - name: Save build artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: newrelic-php-agent/releases - name: release-from-gha + name: release-from-gha-${{ matrix.platform }}-${{ matrix.arch }} if-no-files-found: error diff --git a/.github/workflows/test-agent.yml b/.github/workflows/test-agent.yml index 0365b4ddb..d40384e13 100644 --- a/.github/workflows/test-agent.yml +++ b/.github/workflows/test-agent.yml @@ -58,7 +58,7 @@ jobs: -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" $IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION daemon_test - name: Save integration_runner for integration tests - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: integration_runner-${{matrix.platform}}-${{matrix.arch}} path: php-agent/bin/integration_runner @@ -159,19 +159,19 @@ jobs: -e ENABLE_COVERAGE=${{matrix.codecov}} $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent-${{ steps.get-check-variant.outputs.AGENT_CHECK_VARIANT }} - name: Save newrelic.so for integration tests - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: newrelic.so-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/agent/modules/newrelic.so - name: Save axiom gcov data files (*.gcno, *.gcna) if: ${{ matrix.codecov == 1 }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: axiom.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/axiom/*.gc* - name: Save agent gcov data files (*.gcno, *.gcna) if: ${{ matrix.codecov == 1 }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: agent.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/agent/.libs/*.gc* @@ -206,24 +206,24 @@ jobs: with: path: php-agent - name: Get integration_runner - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: integration_runner-${{matrix.platform}}-${{matrix.arch}} path: php-agent/bin - name: Get newrelic.so - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: newrelic.so-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/agent/modules - name: Get axiom gcov data files if: ${{ matrix.codecov == 1 }} - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: axiom.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/axiom - name: Get agent gcov data files if: ${{ matrix.codecov == 1 }} - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: agent.gcov-${{matrix.platform}}-${{matrix.arch}}-${{matrix.php}} path: php-agent/agent/.libs From d76a34bbc06c3de393614043904fc713a87f7d24 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Thu, 9 May 2024 12:21:26 -0400 Subject: [PATCH 18/44] fix(agent): end guzzle's external segment for rejected request (#883) Modify the onRejected handler to end guzzle's external segment even when there's no response. This allows to mark the span as an external span and capture the uri and method of the request. Additionally when sync requests is rejected, onRejected callback is not called via `PromiseInterface::then` and needs to be called manually. Fixes #320. --------- Co-authored-by: Amber Sistla --- agent/lib_guzzle6.c | 72 ++++---- daemon/cmd/integration_runner/main.go | 11 ++ daemon/internal/newrelic/integration/test.go | 33 ++-- .../newrelic/integration/test_test.go | 69 ++++++++ .../test_bad_response_exception_async.php | 92 ++++++++++ .../test_bad_response_exception_sync.php | 96 ++++++++++ .../external/guzzle6/test_timeout_async.php | 67 +++++++ .../external/guzzle6/test_timeout_sync.php | 67 +++++++ .../guzzle6/test_transfer_exception_async.php | 86 +++++++++ .../guzzle6/test_transfer_exception_sync.php | 90 ++++++++++ ...t_uncaught_bad_response_exception_sync.php | 165 ++++++++++++++++++ ...test_uncaught_transfer_exception_async.php | 161 +++++++++++++++++ .../test_bad_response_exception_async.php | 92 ++++++++++ .../test_bad_response_exception_sync.php | 96 ++++++++++ .../external/guzzle7/test_timeout_async.php | 67 +++++++ .../external/guzzle7/test_timeout_sync.php | 67 +++++++ .../guzzle7/test_transfer_exception_async.php | 86 +++++++++ .../guzzle7/test_transfer_exception_sync.php | 90 ++++++++++ ...t_uncaught_bad_response_exception_sync.php | 165 ++++++++++++++++++ ...test_uncaught_transfer_exception_async.php | 161 +++++++++++++++++ 20 files changed, 1787 insertions(+), 46 deletions(-) create mode 100644 tests/integration/external/guzzle6/test_bad_response_exception_async.php create mode 100644 tests/integration/external/guzzle6/test_bad_response_exception_sync.php create mode 100644 tests/integration/external/guzzle6/test_timeout_async.php create mode 100644 tests/integration/external/guzzle6/test_timeout_sync.php create mode 100644 tests/integration/external/guzzle6/test_transfer_exception_async.php create mode 100644 tests/integration/external/guzzle6/test_transfer_exception_sync.php create mode 100644 tests/integration/external/guzzle6/test_uncaught_bad_response_exception_sync.php create mode 100644 tests/integration/external/guzzle6/test_uncaught_transfer_exception_async.php create mode 100644 tests/integration/external/guzzle7/test_bad_response_exception_async.php create mode 100644 tests/integration/external/guzzle7/test_bad_response_exception_sync.php create mode 100644 tests/integration/external/guzzle7/test_timeout_async.php create mode 100644 tests/integration/external/guzzle7/test_timeout_sync.php create mode 100644 tests/integration/external/guzzle7/test_transfer_exception_async.php create mode 100644 tests/integration/external/guzzle7/test_transfer_exception_sync.php create mode 100644 tests/integration/external/guzzle7/test_uncaught_bad_response_exception_sync.php create mode 100644 tests/integration/external/guzzle7/test_uncaught_transfer_exception_async.php diff --git a/agent/lib_guzzle6.c b/agent/lib_guzzle6.c index 9038c2aaf..a106eac71 100644 --- a/agent/lib_guzzle6.c +++ b/agent/lib_guzzle6.c @@ -112,17 +112,13 @@ static void nr_guzzle6_requesthandler_handle_response(zval* handler, nr_segment_external_params_t external_params = {.library = "Guzzle 6"}; zval* request; zval* method; - zval* status; + zval* status = NULL; if (NR_FAILURE == nr_guzzle_obj_find_and_remove(handler, &segment TSRMLS_CC)) { return; } - if (!nr_php_psr7_is_response(response TSRMLS_CC)) { - return; - } - request = nr_guzzle6_requesthandler_get_request(handler TSRMLS_CC); if (NULL == request) { return; @@ -133,25 +129,6 @@ static void nr_guzzle6_requesthandler_handle_response(zval* handler, return; } - /* - * Get the X-NewRelic-App-Data response header. If there isn't one, NULL is - * returned, and everything still works just fine. - */ - external_params.encoded_response_header - = nr_php_psr7_message_get_header(response, X_NEWRELIC_APP_DATA TSRMLS_CC); - - if (NRPRG(txn) && NRTXN(special_flags.debug_cat)) { - nrl_verbosedebug( - NRL_CAT, "CAT: outbound response: transport='Guzzle 6' %s=" NRP_FMT, - X_NEWRELIC_APP_DATA, NRP_CAT(external_params.encoded_response_header)); - } - - status = nr_php_call(response, "getStatusCode"); - - if (nr_php_is_zval_valid_integer(status)) { - external_params.status = Z_LVAL_P(status); - } - method = nr_php_call(request, "getMethod"); if (nr_php_is_zval_valid_string(method)) { @@ -159,6 +136,27 @@ static void nr_guzzle6_requesthandler_handle_response(zval* handler, = nr_strndup(Z_STRVAL_P(method), Z_STRLEN_P(method)); } + if (NULL != response && nr_php_psr7_is_response(response TSRMLS_CC)) { + /* + * Get the X-NewRelic-App-Data response header. If there isn't one, NULL is + * returned, and everything still works just fine. + */ + external_params.encoded_response_header + = nr_php_psr7_message_get_header(response, X_NEWRELIC_APP_DATA TSRMLS_CC); + + if (NRPRG(txn) && NRTXN(special_flags.debug_cat)) { + nrl_verbosedebug( + NRL_CAT, "CAT: outbound response: transport='Guzzle 6' %s=" NRP_FMT, + X_NEWRELIC_APP_DATA, NRP_CAT(external_params.encoded_response_header)); + } + + status = nr_php_call(response, "getStatusCode"); + + if (nr_php_is_zval_valid_integer(status)) { + external_params.status = Z_LVAL_P(status); + } + } + nr_segment_external_end(&segment, &external_params); nr_free(external_params.encoded_response_header); @@ -291,6 +289,12 @@ static PHP_NAMED_FUNCTION(nr_guzzle6_requesthandler_onrejected) { return; } + this_obj = NR_PHP_USER_FN_THIS(); + if (NULL == this_obj) { + nrl_verbosedebug(NRL_FRAMEWORK, "%s: cannot obtain 'this'", __func__); + return; + } + /* * See if this is an exception that we can get a response from. We're going * to look for BadResponseException because, although it inherits from @@ -305,6 +309,7 @@ static PHP_NAMED_FUNCTION(nr_guzzle6_requesthandler_onrejected) { */ if (!nr_php_object_instanceof_class( exc, "GuzzleHttp\\Exception\\BadResponseException" TSRMLS_CC)) { + nr_guzzle6_requesthandler_handle_response(this_obj, NULL); return; } @@ -314,12 +319,6 @@ static PHP_NAMED_FUNCTION(nr_guzzle6_requesthandler_onrejected) { return; } - this_obj = NR_PHP_USER_FN_THIS(); - if (NULL == this_obj) { - nrl_verbosedebug(NRL_FRAMEWORK, "%s: cannot obtain 'this'", __func__); - return; - } - nr_guzzle6_requesthandler_handle_response(this_obj, response TSRMLS_CC); nr_php_zval_free(&response); @@ -448,6 +447,7 @@ void nr_guzzle6_enable(TSRMLS_D) { "namespace newrelic\\Guzzle6;" "use Psr\\Http\\Message\\RequestInterface;" + "use GuzzleHttp\\Promise\\PromiseInterface;" "if (!function_exists('newrelic\\Guzzle6\\middleware')) {" " function middleware(callable $handler) {" @@ -468,8 +468,16 @@ void nr_guzzle6_enable(TSRMLS_D) { */ " $rh = new RequestHandler($request);" " $promise = $handler($request, $options);" - " $promise->then([$rh, 'onFulfilled'], [$rh, 'onRejected']);" - + " if (PromiseInterface::REJECTED == $promise->getState()) {" + /* + Special case for sync request. When sync requests is rejected, + onRejected callback is not called via `PromiseInterface::then` + and needs to be called manually. + */ + " $rh->onRejected($promise);" + " } else {" + " $promise->then([$rh, 'onFulfilled'], [$rh, 'onRejected']);" + " }" " return $promise;" " };" " }" diff --git a/daemon/cmd/integration_runner/main.go b/daemon/cmd/integration_runner/main.go index f555ffab5..40f472af4 100644 --- a/daemon/cmd/integration_runner/main.go +++ b/daemon/cmd/integration_runner/main.go @@ -245,6 +245,16 @@ func catRequest(w http.ResponseWriter, r *http.Request) { w.Write(body) } +func delayRequest(w http.ResponseWriter, r *http.Request) { + duration := r.URL.Query().Get("duration") + io.WriteString(w, "waiting...") + d, err := time.ParseDuration(duration) + if nil != err { + d = 0 + } + time.Sleep(d) +} + func init() { //setup typed flags flag.Var(&flagLicense, "license", "use a license key other than the hard coded default. Supports @filename syntax for loading from files.") @@ -303,6 +313,7 @@ func main() { io.WriteString(w, "Hello world!") }) mux.HandleFunc("/cat", catRequest) + mux.HandleFunc("/delay", delayRequest) addr := "127.0.0.1:" + strconv.Itoa(*flagExternalPort) srv := &http.Server{Addr: addr, Handler: mux} ln, err := net.Listen("tcp", addr) diff --git a/daemon/internal/newrelic/integration/test.go b/daemon/internal/newrelic/integration/test.go index 37e55f09c..478c349fc 100644 --- a/daemon/internal/newrelic/integration/test.go +++ b/daemon/internal/newrelic/integration/test.go @@ -102,7 +102,7 @@ type Test struct { } func NewTest(name string) *Test { - test := &Test{Name: name} + test := &Test{Name: name, Env: make(map[string]string)} test.SetExpectHarvest(true) return test } @@ -200,14 +200,14 @@ func merge(a, b map[string]string) map[string]string { } func (t *Test) MakeRun(ctx *Context) (Tx, error) { - env := merge(ctx.Env, t.Env) + t.Env = merge(ctx.Env, t.Env) settings := merge(ctx.Settings, t.Settings) settings["newrelic.appname"] = t.Name headers := make(http.Header) for key, vals := range t.headers { for _, v := range vals { - expanded := SubEnvVars([]byte(v)) + expanded := t.subEnvVars([]byte(v)) headers.Set(key, string(expanded)) } } @@ -215,12 +215,12 @@ func (t *Test) MakeRun(ctx *Context) (Tx, error) { settings = merge(settings, t.PhpModules) if t.IsC() { - return CTx(ScriptFile(t.Path), env, settings, headers, ctx) + return CTx(ScriptFile(t.Path), t.Env, settings, headers, ctx) } if t.IsWeb() { - return CgiTx(ScriptFile(t.Path), env, settings, headers, ctx) + return CgiTx(ScriptFile(t.Path), t.Env, settings, headers, ctx) } - return PhpTx(ScriptFile(t.Path), env, settings, ctx) + return PhpTx(ScriptFile(t.Path), t.Env, settings, ctx) } func (t *Test) MakeSkipIf(ctx *Context) (Tx, error) { @@ -228,7 +228,7 @@ func (t *Test) MakeSkipIf(ctx *Context) (Tx, error) { return nil, nil } - env := merge(ctx.Env, t.Env) + t.Env = merge(ctx.Env, t.Env) settings := merge(ctx.Settings, t.Settings) settings["newrelic.appname"] = "skipif" @@ -239,7 +239,7 @@ func (t *Test) MakeSkipIf(ctx *Context) (Tx, error) { data: t.rawSkipIf, } - return PhpTx(src, env, settings, ctx) + return PhpTx(src, t.Env, settings, ctx) } type Scrub struct { @@ -285,10 +285,15 @@ func ScrubHost(in []byte) []byte { return re.ReplaceAll(in, []byte("__HOST__")) } -func SubEnvVars(in []byte) []byte { +func (t *Test) subEnvVars(in []byte) []byte { re := regexp.MustCompile("ENV\\[.*?\\]") return re.ReplaceAllFunc(in, func(match []byte) []byte { - return []byte(os.Getenv(string(match[4 : len(match)-1]))) + k := string(match[4 : len(match)-1]) + v, present := t.Env[k] + if !present { + v = os.Getenv(k) + } + return []byte(v) }) } @@ -345,7 +350,7 @@ func (t *Test) compareSpanEventsLike(harvest *newrelic.Harvest) { return } - if err := json.Unmarshal(t.spanEventsLike, &x2); nil != err { + if err := json.Unmarshal(t.subEnvVars(t.spanEventsLike), &x2); nil != err { t.Fatal(fmt.Errorf("unable to parse expected spans like json for fuzzy matching: %v", err)) return } @@ -497,7 +502,7 @@ func (t *Test) comparePayload(expected json.RawMessage, pc newrelic.PayloadCreat } } - expected = SubEnvVars(expected) + expected = t.subEnvVars(expected) err = IsFuzzyMatch(expected, actual) if nil != err { @@ -679,7 +684,7 @@ func (t *Test) Compare(harvest *newrelic.Harvest) { } if nil != t.metricsExist { - for _, name := range strings.Split(strings.TrimSpace(string(t.metricsExist)), "\n") { + for _, name := range strings.Split(strings.TrimSpace(string(t.subEnvVars(t.metricsExist))), "\n") { name = strings.TrimSpace(name) actual := strings.Replace(name, "__FILE__", t.Path, -1) if !harvest.Metrics.Has(actual) { @@ -689,7 +694,7 @@ func (t *Test) Compare(harvest *newrelic.Harvest) { } if nil != t.metricsDontExist { - for _, name := range strings.Split(strings.TrimSpace(string(t.metricsDontExist)), "\n") { + for _, name := range strings.Split(strings.TrimSpace(string(t.subEnvVars(t.metricsDontExist))), "\n") { name = strings.TrimSpace(name) actual := strings.Replace(name, "__FILE__", t.Path, -1) if harvest.Metrics.Has(actual) { diff --git a/daemon/internal/newrelic/integration/test_test.go b/daemon/internal/newrelic/integration/test_test.go index 582109def..891730bfa 100644 --- a/daemon/internal/newrelic/integration/test_test.go +++ b/daemon/internal/newrelic/integration/test_test.go @@ -7,6 +7,7 @@ package integration import ( "bytes" + "maps" "testing" "github.com/newrelic/newrelic-php-agent/daemon/internal/newrelic/sysinfo" @@ -62,3 +63,71 @@ func TestScrubHost(t *testing.T) { } } } + +func TestSubsEnvVar(t *testing.T) { + k := "TEST_KEY" + v := "test_value" + test := NewTest("SubsEnvVar") + test.Env[k] = v + + tests := []struct { + in []byte + want []byte + }{ + { + in: []byte("External/ENV[" + k + "]/all"), + want: []byte("External/" + v + "/all"), + }, + { + in: []byte("External/ENV[NON_EXISTING_KEY]/all"), + want: []byte("External//all"), + }, + } + + for i, tt := range tests { + if got := test.subEnvVars(tt.in); !bytes.Equal(got, tt.want) { + t.Errorf("%d. Test.subsEnvVar(%q) = %q; want %q", i, tt.in, got, tt.want) + } + } +} + +func makeTestWithEnv(name string, e map[string]string) *Test { + t := NewTest(name) + if nil != e { + maps.Copy(t.Env, e) + } + return t +} + +func TestMerge(t *testing.T) { + m1_k := "OS_KEY" + m1_v := "os_value" + m2_k := "TEST_KEY" + m2_v := "test_value" + m1 := map[string]string{ + m1_k: m1_v, + } + m2 := map[string]string{ + m2_k: m2_v, + } + same_key_diff_val := map[string]string{ + m1_k: m2_v, + } + tests := []struct { + name string + m map[string]string + k string + want string + }{ + {name: "MergeEmptyMap", m: nil, k: m1_k, want: m1_v}, + {name: "MergeDiffMaps", m: m2, k: m1_k, want: m1_v}, + {name: "MergeMapWithSameKeys", m: same_key_diff_val, k: m1_k, want: m2_v}, + } + for i, tt := range tests { + mm := merge(m1, tt.m) + got := mm[tt.k] + if got != tt.want { + t.Errorf("%d. %s - got: %s; want %s", i, tt.name, got, tt.want) + } + } +} diff --git a/tests/integration/external/guzzle6/test_bad_response_exception_async.php b/tests/integration/external/guzzle6/test_bad_response_exception_async.php new file mode 100644 index 000000000..528d81c75 --- /dev/null +++ b/tests/integration/external/guzzle6/test_bad_response_exception_async.php @@ -0,0 +1,92 @@ + $stack, + +]); + +$promise = $client->sendAsync($request); +GuzzleHttp\Promise\Utils::settle($promise)->wait(); + +echo "all's well that ends well" . PHP_EOL; diff --git a/tests/integration/external/guzzle6/test_bad_response_exception_sync.php b/tests/integration/external/guzzle6/test_bad_response_exception_sync.php new file mode 100644 index 000000000..bed8d8b7b --- /dev/null +++ b/tests/integration/external/guzzle6/test_bad_response_exception_sync.php @@ -0,0 +1,96 @@ + $stack, + +]); + +try { + $response = $client->send($request); +} catch (GuzzleHttp\Exception\BadResponseException $e) { + echo "gotcha!". PHP_EOL; +} + +echo "all's well that ends well" . PHP_EOL; diff --git a/tests/integration/external/guzzle6/test_timeout_async.php b/tests/integration/external/guzzle6/test_timeout_async.php new file mode 100644 index 000000000..caafd4d68 --- /dev/null +++ b/tests/integration/external/guzzle6/test_timeout_async.php @@ -0,0 +1,67 @@ + "$EXTERNAL_HOST", + // Set a short timeout, shorter than delay duration in the request + 'timeout' => 0.01, +]); + +$promise = $client->getAsync('/delay?duration=100ms'); +GuzzleHttp\Promise\Utils::settle($promise)->wait(); diff --git a/tests/integration/external/guzzle6/test_timeout_sync.php b/tests/integration/external/guzzle6/test_timeout_sync.php new file mode 100644 index 000000000..8ae5428f1 --- /dev/null +++ b/tests/integration/external/guzzle6/test_timeout_sync.php @@ -0,0 +1,67 @@ + "$EXTERNAL_HOST", + // Set a short timeout, shorter than delay duration in the request + 'timeout' => 0.01, +]); + +$response = $client->get('/delay?duration=100ms'); + diff --git a/tests/integration/external/guzzle6/test_transfer_exception_async.php b/tests/integration/external/guzzle6/test_transfer_exception_async.php new file mode 100644 index 000000000..924f466d0 --- /dev/null +++ b/tests/integration/external/guzzle6/test_transfer_exception_async.php @@ -0,0 +1,86 @@ + $stack, +]); + +$promise = $client->sendAsync($request); +GuzzleHttp\Promise\Utils::settle($promise)->wait(); + +echo "all's well that ends well" . PHP_EOL; diff --git a/tests/integration/external/guzzle6/test_transfer_exception_sync.php b/tests/integration/external/guzzle6/test_transfer_exception_sync.php new file mode 100644 index 000000000..42387ae13 --- /dev/null +++ b/tests/integration/external/guzzle6/test_transfer_exception_sync.php @@ -0,0 +1,90 @@ + $stack, +]); + +try { + $response = $client->send($request); +} catch (\GuzzleHttp\Exception\TransferException $e) { + echo "gotcha!". PHP_EOL; +} + +echo "all's well that ends well" . PHP_EOL; diff --git a/tests/integration/external/guzzle6/test_uncaught_bad_response_exception_sync.php b/tests/integration/external/guzzle6/test_uncaught_bad_response_exception_sync.php new file mode 100644 index 000000000..9f9a28af7 --- /dev/null +++ b/tests/integration/external/guzzle6/test_uncaught_bad_response_exception_sync.php @@ -0,0 +1,165 @@ + $stack, + +]); + +$response = $client->send($request); + +echo "you should not see this" . PHP_EOL; diff --git a/tests/integration/external/guzzle6/test_uncaught_transfer_exception_async.php b/tests/integration/external/guzzle6/test_uncaught_transfer_exception_async.php new file mode 100644 index 000000000..b6643cb4f --- /dev/null +++ b/tests/integration/external/guzzle6/test_uncaught_transfer_exception_async.php @@ -0,0 +1,161 @@ + $stack, +]); + +$promise = $client->sendAsync($request); +$promise->wait(); + +echo "you should not see this" . PHP_EOL; diff --git a/tests/integration/external/guzzle7/test_bad_response_exception_async.php b/tests/integration/external/guzzle7/test_bad_response_exception_async.php new file mode 100644 index 000000000..2047d4b09 --- /dev/null +++ b/tests/integration/external/guzzle7/test_bad_response_exception_async.php @@ -0,0 +1,92 @@ + $stack, + +]); + +$promise = $client->sendAsync($request); +GuzzleHttp\Promise\Utils::settle($promise)->wait(); + +echo "all's well that ends well" . PHP_EOL; diff --git a/tests/integration/external/guzzle7/test_bad_response_exception_sync.php b/tests/integration/external/guzzle7/test_bad_response_exception_sync.php new file mode 100644 index 000000000..95cba3426 --- /dev/null +++ b/tests/integration/external/guzzle7/test_bad_response_exception_sync.php @@ -0,0 +1,96 @@ + $stack, + +]); + +try { + $response = $client->send($request); +} catch (\GuzzleHttp\Exception\BadResponseException $e) { + echo "gotcha!". PHP_EOL; +} + +echo "all's well that ends well" . PHP_EOL; diff --git a/tests/integration/external/guzzle7/test_timeout_async.php b/tests/integration/external/guzzle7/test_timeout_async.php new file mode 100644 index 000000000..3f062c554 --- /dev/null +++ b/tests/integration/external/guzzle7/test_timeout_async.php @@ -0,0 +1,67 @@ + "$EXTERNAL_HOST", + // Set a short timeout, shorter than delay duration in the request + 'timeout' => 0.01, +]); + +$promise = $client->getAsync('/delay?duration=100ms'); +GuzzleHttp\Promise\Utils::settle($promise)->wait(); diff --git a/tests/integration/external/guzzle7/test_timeout_sync.php b/tests/integration/external/guzzle7/test_timeout_sync.php new file mode 100644 index 000000000..f01ae9047 --- /dev/null +++ b/tests/integration/external/guzzle7/test_timeout_sync.php @@ -0,0 +1,67 @@ + "$EXTERNAL_HOST", + // Set a short timeout, shorter than delay duration in the request + 'timeout' => 0.01, +]); + +$response = $client->get('/delay?duration=100ms'); + diff --git a/tests/integration/external/guzzle7/test_transfer_exception_async.php b/tests/integration/external/guzzle7/test_transfer_exception_async.php new file mode 100644 index 000000000..40e2e794f --- /dev/null +++ b/tests/integration/external/guzzle7/test_transfer_exception_async.php @@ -0,0 +1,86 @@ + $stack, +]); + +$promise = $client->sendAsync($request); +GuzzleHttp\Promise\Utils::settle($promise)->wait(); + +echo "all's well that ends well" . PHP_EOL; diff --git a/tests/integration/external/guzzle7/test_transfer_exception_sync.php b/tests/integration/external/guzzle7/test_transfer_exception_sync.php new file mode 100644 index 000000000..196ec3273 --- /dev/null +++ b/tests/integration/external/guzzle7/test_transfer_exception_sync.php @@ -0,0 +1,90 @@ + $stack, +]); + +try { + $response = $client->send($request); +} catch (\GuzzleHttp\Exception\TransferException $e) { + echo "gotcha!". PHP_EOL; +} + +echo "all's well that ends well" . PHP_EOL; diff --git a/tests/integration/external/guzzle7/test_uncaught_bad_response_exception_sync.php b/tests/integration/external/guzzle7/test_uncaught_bad_response_exception_sync.php new file mode 100644 index 000000000..88e2acdaf --- /dev/null +++ b/tests/integration/external/guzzle7/test_uncaught_bad_response_exception_sync.php @@ -0,0 +1,165 @@ + $stack, + +]); + +$response = $client->send($request); + +echo "you should not see this" . PHP_EOL; diff --git a/tests/integration/external/guzzle7/test_uncaught_transfer_exception_async.php b/tests/integration/external/guzzle7/test_uncaught_transfer_exception_async.php new file mode 100644 index 000000000..56641dacd --- /dev/null +++ b/tests/integration/external/guzzle7/test_uncaught_transfer_exception_async.php @@ -0,0 +1,161 @@ + $stack, +]); + +$promise = $client->sendAsync($request); +$promise->wait(); + +echo "you should not see this" . PHP_EOL; From 206ee18466bfd463f7df38d9a5de058fdbe461d4 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Mon, 6 May 2024 15:27:37 -0400 Subject: [PATCH 19/44] update go minimum version --- daemon/go.mod | 2 +- go.work | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/go.mod b/daemon/go.mod index 06d57f2a1..4f5e56e04 100644 --- a/daemon/go.mod +++ b/daemon/go.mod @@ -1,6 +1,6 @@ module github.com/newrelic/newrelic-php-agent/daemon -go 1.21.1 +go 1.22.2 require ( github.com/golang/protobuf v1.5.3 diff --git a/go.work b/go.work index 05e497662..f12703c8e 100644 --- a/go.work +++ b/go.work @@ -1,3 +1,3 @@ -go 1.21.1 +go 1.22.2 use ./daemon From a7b7febe60f0cdb69b9758039edc61754d45e2d2 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Mon, 6 May 2024 15:29:21 -0400 Subject: [PATCH 20/44] remove unneeded targets daemon module dependencies are defined in go.mod and go downloads them automatically at build time. There's no need to download them to vendor subdir separately. --- daemon/Makefile | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/daemon/Makefile b/daemon/Makefile index 145d51147..6d2aca5fa 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -46,21 +46,13 @@ clean: clean-bin: $(GO) clean $(GOFLAGS) -i ./... -# setup depenencies for daemon -# THIS IS TEMPORARY NEEDS TO BE REPLACED BY PINNED VENDOR DEPENDENCIES -# will download vendor dependencies -.PHONY: go-setup-dependencies -go-setup-dependencies: - $(GO) mod tidy - $(GO) mod vendor - # Build the binaries .PHONY: $(BINARIES) -$(BINARIES): clean-bin go-setup-dependencies +$(BINARIES): clean-bin $(GO) install $(GOFLAGS) $(GO_MODULE)/cmd/$@ # the -race flag enabled the integrated Go race detector. Output to stderr. -race: clean-bin go-setup-dependencies +race: clean-bin $(GO) install -race $(GOFLAGS) $(GO_MODULE)/$@ # Test targets @@ -76,10 +68,10 @@ cover: rm -f $(DAEMON_COV_FILE) .PHONY: integration -integration: go-setup-dependencies +integration: $(GO) test $(GOFLAGS) -tags integration ./... .PHONY: test -test: go-setup-dependencies +test: $(GO) test $(GOFLAGS) ./... From 422d79aedb23117a1cbcf3b3635440ca3e1d198a Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Tue, 7 May 2024 14:12:44 -0400 Subject: [PATCH 21/44] test v3 of make-go variant Use v3 of make-go when building daemon. --- .github/workflows/test-agent.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-agent.yml b/.github/workflows/test-agent.yml index d40384e13..318e5c54b 100644 --- a/.github/workflows/test-agent.yml +++ b/.github/workflows/test-agent.yml @@ -24,7 +24,7 @@ jobs: env: IMAGE_NAME: newrelic/nr-php-agent-builder IMAGE_TAG: make-go - IMAGE_VERSION: ${{vars.MAKE_GO_VERSION}} + IMAGE_VERSION: v3 strategy: matrix: platform: [gnu, musl] From 884ac586a22d1a78376fb2f183cebb17af9e8def Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Fri, 10 May 2024 16:27:13 -0400 Subject: [PATCH 22/44] customize codeql Use go in the version required by the daemon. Use manual build instead of autobuild. --- .github/workflows/codeql.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 3c2334186..85146ee58 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -36,11 +36,18 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Setup go + if: ${{ matrix.language == 'go' }} + uses: actions/setup-go@v5 + with: + go-version-file: './daemon/go.mod' + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} + build-mode: manual # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. @@ -48,21 +55,18 @@ jobs: # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + - name: Build agent + if: ${{ matrix.language == 'c-cpp' }} + run: | + make agent - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + - name: Build daemon + if: ${{ matrix.language == 'go' }} + run: | + make daemon - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 From ef38aa861a1f9ae05d9a60d54f450f4b8c5129ce Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Mon, 13 May 2024 15:09:04 -0400 Subject: [PATCH 23/44] remove `go.work` `go.work` is no longer compatible with newrelic-php-agent project structure. go1.22 includes changes to how a `vendor` directory in a project is used: > Commands in workspaces can now use a `vendor` directory containing the > dependencies of the workspace. The directory is created by `go work vendor`, > and used by build commands when the `-mod` flag is set to `vendor`, which is > the default when a workspace `vendor` directory is present. newrelic-php-agent project already contains a `vendor` directory. However, it contains agent's dependencies, which is incompatible with what go1.22 expects: go workspace modules' vendored dependencies. Any `go work vendor` operation overwrites contents of `vendor` directory. Moreover, `go.work` is not needed in newrelic-php-agent, because this project is not a multi-module go project, but rather a PHP extension project with one go module - newrelic-daemon. newrelic-daemon is a self contained module with its code under `daemon` directory. --- go.work | 3 --- go.work.sum | 1 - 2 files changed, 4 deletions(-) delete mode 100644 go.work delete mode 100644 go.work.sum diff --git a/go.work b/go.work deleted file mode 100644 index f12703c8e..000000000 --- a/go.work +++ /dev/null @@ -1,3 +0,0 @@ -go 1.22.2 - -use ./daemon diff --git a/go.work.sum b/go.work.sum deleted file mode 100644 index 207fd9712..000000000 --- a/go.work.sum +++ /dev/null @@ -1 +0,0 @@ -google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 h1:wpZ8pe2x1Q3f2KyT5f8oP/fa9rHAKgFPr/HZdNuS+PQ= From 38ec7b6cda59e2385695ea99a4899b479661e2f7 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Tue, 14 May 2024 00:39:56 -0400 Subject: [PATCH 24/44] fix use of `go` directive in `go.mod` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From "Go Modules Reference": > A `go` directive indicates that a module was written assuming the semantics > of a given version of Go. […] The `go` directive sets the minimum version > of Go required to use this module. Daemon module source code is not using any language features newer than 1.9. However, go 1.21 changed semantics of `go` directive in `go.mod`: > At go 1.21 or higher: > * The go line declares a required minimum version of Go to use with this > module. > * The go line must be greater than or equal to the go line of all > dependencies. > * The go command no longer attempts to maintain compatibility with the > previous older version of Go. > * The go command is more careful about keeping checksums of go.mod files > in the go.sum file. These new semantics are beneficial for daemon therefore daemon module will use go 1.21. On the other hand, daemon needs to be built with the latest possible toolchain, hence the use of `toolchain` directive, which will enforce use of toolchain in the desired version. --- daemon/go.mod | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/daemon/go.mod b/daemon/go.mod index 4f5e56e04..41f8c79ed 100644 --- a/daemon/go.mod +++ b/daemon/go.mod @@ -1,6 +1,7 @@ module github.com/newrelic/newrelic-php-agent/daemon -go 1.22.2 +go 1.21 +toolchain go1.22.3 require ( github.com/golang/protobuf v1.5.3 From 59f4375ab8a43ee2c8e4a2600ad84a02fc90ead8 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Tue, 14 May 2024 00:54:39 -0400 Subject: [PATCH 25/44] simplify codeql workflow Use of `toolchain` directive in daemon's go.mod obsoletes setup-go step: daemon build will use version of go toolchain requested in `toolchain` directive. --- .github/workflows/codeql.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 85146ee58..0feeeced2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -36,12 +36,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup go - if: ${{ matrix.language == 'go' }} - uses: actions/setup-go@v5 - with: - go-version-file: './daemon/go.mod' - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 From 9a17dc106ff43a197f846a70f0369c7380cf3f5e Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Wed, 15 May 2024 11:03:55 -0400 Subject: [PATCH 26/44] revert 422d79aedb23117a1cbcf3b3635440ca3e1d198a --- .github/workflows/test-agent.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-agent.yml b/.github/workflows/test-agent.yml index 318e5c54b..d40384e13 100644 --- a/.github/workflows/test-agent.yml +++ b/.github/workflows/test-agent.yml @@ -24,7 +24,7 @@ jobs: env: IMAGE_NAME: newrelic/nr-php-agent-builder IMAGE_TAG: make-go - IMAGE_VERSION: v3 + IMAGE_VERSION: ${{vars.MAKE_GO_VERSION}} strategy: matrix: platform: [gnu, musl] From c550edd0ae06d1ddc9ac9ad7cdbd94adc3f173cf Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Wed, 15 May 2024 11:06:41 -0400 Subject: [PATCH 27/44] simplify codeql workflow Use GitHub Actions expressions syntax to select correct target for the build step: daemon for Go and agent for C. --- .github/workflows/codeql.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0feeeced2..c715fe73b 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -52,15 +52,9 @@ jobs: # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - name: Build agent - if: ${{ matrix.language == 'c-cpp' }} + - name: Build run: | - make agent - - - name: Build daemon - if: ${{ matrix.language == 'go' }} - run: | - make daemon + make ${{ matrix.language == 'go' && 'daemon' || 'agent' }} - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 From 2c60b2019e683fabfa1e553844c21523b2391d6e Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Wed, 20 Mar 2024 14:53:01 -0600 Subject: [PATCH 28/44] refactor(agent): remove oapi 'clean' callback --- agent/fw_cakephp.c | 4 +- agent/fw_drupal.c | 39 +++----- agent/fw_drupal8.c | 24 ++--- agent/fw_laravel.c | 12 +-- agent/fw_laravel_queue.c | 16 ++-- agent/fw_lumen.c | 4 +- agent/fw_magento2.c | 16 ++-- agent/fw_symfony4.c | 4 +- agent/fw_wordpress.c | 30 +++---- agent/fw_yii.c | 5 +- agent/lib_doctrine2.c | 10 +-- agent/lib_predis.c | 29 ++---- agent/php_execute.c | 13 +-- agent/php_newrelic.h | 2 +- agent/php_user_instrument.c | 16 ---- agent/php_user_instrument.h | 10 +-- agent/php_wrapper.c | 48 ++++------ agent/php_wrapper.h | 17 ++-- agent/tests/test_php_wrapper.c | 36 ++++---- .../frameworks/drupal/mock_module_handler.php | 5 ++ .../drupal/test_invoke_all_with.php | 5 +- tests/integration/test_simple.php | 88 +++++++++++++++++++ 22 files changed, 214 insertions(+), 219 deletions(-) create mode 100644 tests/integration/test_simple.php diff --git a/agent/fw_cakephp.c b/agent/fw_cakephp.c index 1dfe88231..c956b4de0 100644 --- a/agent/fw_cakephp.c +++ b/agent/fw_cakephp.c @@ -331,8 +331,8 @@ void nr_cakephp_enable_2(TSRMLS_D) { nr_cakephp_name_the_wt_2 TSRMLS_CC); #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("CakeException::__construct"), nr_cakephp_problem_2, NULL, NULL); + nr_php_wrap_user_function_before_after( + NR_PSTR("CakeException::__construct"), nr_cakephp_problem_2, NULL); #else nr_php_wrap_user_function(NR_PSTR("CakeException::__construct"), nr_cakephp_problem_2 TSRMLS_CC); diff --git a/agent/fw_drupal.c b/agent/fw_drupal.c index 67efc1dab..cbb2db852 100644 --- a/agent/fw_drupal.c +++ b/agent/fw_drupal.c @@ -301,10 +301,10 @@ NR_PHP_WRAPPER(nr_drupal_http_request_after) { = nr_drupal_http_request_get_method(NR_EXECUTE_ORIG_ARGS); external_params.encoded_response_header - = nr_drupal_http_request_get_response_header(&func_return_value); + = nr_drupal_http_request_get_response_header(NR_GET_RETURN_VALUE_PTR); external_params.status - = nr_drupal_http_request_get_response_code(&func_return_value); + = nr_drupal_http_request_get_response_code(NR_GET_RETURN_VALUE_PTR); if (NRPRG(txn) && NRTXN(special_flags.debug_cat)) { nrl_verbosedebug( NRL_CAT, "CAT: outbound response: transport='Drupal 6-7' %s=" NRP_FMT, @@ -327,16 +327,6 @@ NR_PHP_WRAPPER(nr_drupal_http_request_after) { } NR_PHP_WRAPPER_END -NR_PHP_WRAPPER(nr_drupal_http_request_clean) { - NR_UNUSED_SPECIALFN; - NR_UNUSED_FUNC_RETURN_VALUE; - (void)wraprec; - - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_DRUPAL); - - NRPRG(drupal_http_request_depth) -= 1; -} -NR_PHP_WRAPPER_END #else /* @@ -774,14 +764,6 @@ NR_PHP_WRAPPER(nr_drupal_wrap_module_invoke_all_after) { } NR_PHP_WRAPPER_END -NR_PHP_WRAPPER(nr_drupal_wrap_module_invoke_all_clean) { - NR_UNUSED_SPECIALFN; - NR_UNUSED_FUNC_RETURN_VALUE; - (void)wraprec; - nr_drupal_invoke_all_hook_stacks_pop(); -} -NR_PHP_WRAPPER_END - #else NR_PHP_WRAPPER(nr_drupal_wrap_module_invoke_all) { zval* hook = NULL; @@ -830,14 +812,14 @@ void nr_drupal_enable(TSRMLS_D) { nr_drupal_cron_run TSRMLS_CC); #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("QFormBase::Run"), nr_drupal_qdrupal_name_the_wt, NULL, NULL); - nr_php_wrap_user_function_before_after_clean( + nr_php_wrap_user_function_before_after( + NR_PSTR("QFormBase::Run"), nr_drupal_qdrupal_name_the_wt, NULL); + nr_php_wrap_user_function_before_after( NR_PSTR("drupal_page_cache_header"), nr_drupal_name_wt_as_cached_page, - NULL, NULL); - nr_php_wrap_user_function_before_after_clean( + NULL); + nr_php_wrap_user_function_before_after( NR_PSTR("drupal_http_request"), nr_drupal_http_request_before, - nr_drupal_http_request_after, nr_drupal_http_request_clean); + nr_drupal_http_request_after); #else nr_php_wrap_user_function(NR_PSTR("QFormBase::Run"), nr_drupal_qdrupal_name_the_wt TSRMLS_CC); @@ -856,10 +838,9 @@ void nr_drupal_enable(TSRMLS_D) { nr_drupal_wrap_module_invoke TSRMLS_CC); #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_php_wrap_user_function_before_after( NR_PSTR("module_invoke_all"), nr_drupal_wrap_module_invoke_all_before, - nr_drupal_wrap_module_invoke_all_after, - nr_drupal_wrap_module_invoke_all_clean); + nr_drupal_wrap_module_invoke_all_after); #else nr_php_wrap_user_function(NR_PSTR("module_invoke_all"), nr_drupal_wrap_module_invoke_all TSRMLS_CC); diff --git a/agent/fw_drupal8.c b/agent/fw_drupal8.c index 6593e17a8..497246eb3 100644 --- a/agent/fw_drupal8.c +++ b/agent/fw_drupal8.c @@ -76,13 +76,12 @@ static void nr_drupal8_add_method_callback(const zend_class_entry* ce, #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA -static void nr_drupal8_add_method_callback_before_after_clean( +static void nr_drupal8_add_method_callback_before_after( const zend_class_entry* ce, const char* method, size_t method_len, nrspecialfn_t before_callback, - nrspecialfn_t after_callback, - nrspecialfn_t clean_callback) { + nrspecialfn_t after_callback) { zend_function* function = NULL; if (NULL == ce) { @@ -106,9 +105,9 @@ static void nr_drupal8_add_method_callback_before_after_clean( "%.*s::%.*s", NRSAFELEN(nr_php_class_entry_name_length(ce)), nr_php_class_entry_name(ce), NRSAFELEN(method_len), method); - nr_php_wrap_user_function_before_after_clean( + nr_php_wrap_user_function_before_after( class_method, nr_strlen(class_method), - before_callback, after_callback, clean_callback); + before_callback, after_callback); nr_free(class_method); } @@ -542,12 +541,6 @@ NR_PHP_WRAPPER(nr_drupal94_invoke_all_with_after) { nr_drupal_invoke_all_hook_stacks_pop(); } NR_PHP_WRAPPER_END - -NR_PHP_WRAPPER(nr_drupal94_invoke_all_with_clean) { - (void)wraprec; - nr_drupal_invoke_all_hook_stacks_pop(); -} -NR_PHP_WRAPPER_END #endif // OAPI /* @@ -584,11 +577,10 @@ NR_PHP_WRAPPER(nr_drupal8_module_handler) { /* Drupal 9.4 introduced a replacement method for getImplentations */ #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA - nr_drupal8_add_method_callback_before_after_clean( + nr_drupal8_add_method_callback_before_after( ce, NR_PSTR("invokeallwith"), nr_drupal94_invoke_all_with, - nr_drupal94_invoke_all_with_after, - nr_drupal94_invoke_all_with_clean); + nr_drupal94_invoke_all_with_after); #else nr_drupal8_add_method_callback(ce, NR_PSTR("invokeallwith"), nr_drupal94_invoke_all_with TSRMLS_CC); @@ -711,10 +703,10 @@ void nr_drupal8_enable(TSRMLS_D) { */ #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_php_wrap_user_function_before_after( NR_PSTR("Symfony\\Component\\HttpKernel\\EventListe" "ner\\RouterListener::onKernelRequest"), - nr_drupal8_name_the_wt_via_symfony, NULL, NULL); + nr_drupal8_name_the_wt_via_symfony, NULL); #else nr_php_wrap_user_function(NR_PSTR("Symfony\\Component\\HttpKernel\\EventListe" "ner\\RouterListener::onKernelRequest"), diff --git a/agent/fw_laravel.c b/agent/fw_laravel.c index 11718a7e6..14651f1ff 100644 --- a/agent/fw_laravel.c +++ b/agent/fw_laravel.c @@ -772,8 +772,8 @@ static void nr_laravel5_wrap_middleware(zval* app TSRMLS_DC) { Z_STRVAL_P(classname)); #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA - nr_php_wrap_user_function_before_after_clean( - name, nr_strlen(name), nr_laravel5_middleware_handle, NULL, NULL); + nr_php_wrap_user_function_before_after( + name, nr_strlen(name), nr_laravel5_middleware_handle, NULL); #else nr_php_wrap_user_function(name, nr_strlen(name), nr_laravel5_middleware_handle TSRMLS_CC); @@ -833,8 +833,8 @@ static void nr_laravel_add_callback_method(const zend_class_entry* ce, #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA - nr_php_wrap_user_function_before_after_clean( - class_method, nr_strlen(class_method), callback, NULL, NULL); + nr_php_wrap_user_function_before_after( + class_method, nr_strlen(class_method), callback, NULL); #else nr_php_wrap_user_function(class_method, nr_strlen(class_method), callback TSRMLS_CC); @@ -1230,9 +1230,9 @@ void nr_laravel_enable(TSRMLS_D) { */ #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_php_wrap_user_function_before_after( NR_PSTR("Illuminate\\Console\\Application::doRun"), - nr_laravel_console_application_dorun, NULL, NULL); + nr_laravel_console_application_dorun, NULL); #else nr_php_wrap_user_function(NR_PSTR("Illuminate\\Console\\Application::doRun"), nr_laravel_console_application_dorun TSRMLS_CC); diff --git a/agent/fw_laravel_queue.c b/agent/fw_laravel_queue.c index b4d5576e7..a972236f6 100644 --- a/agent/fw_laravel_queue.c +++ b/agent/fw_laravel_queue.c @@ -864,18 +864,18 @@ void nr_laravel_queue_enable(TSRMLS_D) { * took. */ - nr_php_wrap_user_function_before_after_clean( + nr_php_wrap_user_function_before_after( NR_PSTR("Illuminate\\Queue\\Worker::raiseBeforeJobEvent"), NULL, - nr_laravel_queue_worker_raiseBeforeJobEvent_after, NULL); - nr_php_wrap_user_function_before_after_clean( + nr_laravel_queue_worker_raiseBeforeJobEvent_after); + nr_php_wrap_user_function_before_after( NR_PSTR("Illuminate\\Queue\\Worker::raiseAfterJobEvent"), - nr_laravel_queue_worker_raiseAfterJobEvent_before, NULL, NULL); - nr_php_wrap_user_function_before_after_clean( + nr_laravel_queue_worker_raiseAfterJobEvent_before, NULL); + nr_php_wrap_user_function_before_after( NR_PSTR("Illuminate\\Queue\\SyncQueue::raiseBeforeJobEvent"), - nr_laravel_queue_syncqueue_raiseBeforeJobEvent_before, NULL, NULL); - nr_php_wrap_user_function_before_after_clean( + nr_laravel_queue_syncqueue_raiseBeforeJobEvent_before, NULL); + nr_php_wrap_user_function_before_after( NR_PSTR("Illuminate\\Queue\\SyncQueue::raiseAfterJobEvent"), - nr_laravel_queue_worker_raiseAfterJobEvent_before, NULL, NULL); + nr_laravel_queue_worker_raiseAfterJobEvent_before, NULL); #else diff --git a/agent/fw_lumen.c b/agent/fw_lumen.c index 239578ae1..ee8b3bb0e 100644 --- a/agent/fw_lumen.c +++ b/agent/fw_lumen.c @@ -222,9 +222,9 @@ void nr_lumen_enable(TSRMLS_D) { nr_lumen_handle_found_route TSRMLS_CC); #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_php_wrap_user_function_before_after( NR_PSTR("Laravel\\Lumen\\Application::sendExceptionToHandler"), - nr_lumen_exception, NULL, NULL); + nr_lumen_exception, NULL); #else nr_php_wrap_user_function( NR_PSTR("Laravel\\Lumen\\Application::sendExceptionToHandler"), diff --git a/agent/fw_magento2.c b/agent/fw_magento2.c index f96994f25..e67f2858b 100644 --- a/agent/fw_magento2.c +++ b/agent/fw_magento2.c @@ -440,9 +440,9 @@ void nr_magento2_enable(TSRMLS_D) { */ #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_php_wrap_user_function_before_after( NR_PSTR("Magento\\Framework\\App\\Action\\Action::dispatch"), - nr_magento2_action_dispatch, NULL, NULL); + nr_magento2_action_dispatch, NULL); #else nr_php_wrap_user_function( NR_PSTR("Magento\\Framework\\App\\Action\\Action::dispatch"), @@ -472,10 +472,10 @@ void nr_magento2_enable(TSRMLS_D) { */ #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_php_wrap_user_function_before_after( NR_PSTR( "Magento\\Webapi\\Controller\\Rest\\InputParamsResolver::resolve"), - nr_magento2_inputparamsresolver_resolve, NULL, NULL); + nr_magento2_inputparamsresolver_resolve, NULL); #else nr_php_wrap_user_function( NR_PSTR( @@ -497,14 +497,14 @@ void nr_magento2_enable(TSRMLS_D) { nr_magento2_soap_iswsdllistrequest TSRMLS_CC); #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_php_wrap_user_function_before_after( NR_PSTR("Magento\\Webapi\\Controller\\Soap\\Request\\Handler::_" "prepareRequestData"), - nr_magento2_soap_handler_preparerequestdata, NULL, NULL); - nr_php_wrap_user_function_before_after_clean( + nr_magento2_soap_handler_preparerequestdata, NULL); + nr_php_wrap_user_function_before_after( NR_PSTR("Magento\\Webapi\\Controller\\Soap\\Request\\Handler::" "prepareOperationInput"), - nr_magento2_soap_handler_prepareoperationinput, NULL, NULL); + nr_magento2_soap_handler_prepareoperationinput, NULL); #else nr_php_wrap_user_function( diff --git a/agent/fw_symfony4.c b/agent/fw_symfony4.c index 6e1c9982d..7a1e436d4 100644 --- a/agent/fw_symfony4.c +++ b/agent/fw_symfony4.c @@ -267,9 +267,9 @@ void nr_symfony4_enable(TSRMLS_D) { */ #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_php_wrap_user_function_before_after( NR_PSTR("Symfony\\Component\\Console\\Command\\Command::run"), - nr_symfony4_console_application_run, NULL, NULL); + nr_symfony4_console_application_run, NULL); #else nr_php_wrap_user_function( NR_PSTR("Symfony\\Component\\Console\\Command\\Command::run"), diff --git a/agent/fw_wordpress.c b/agent/fw_wordpress.c index 55a0be5f0..b80b07fd2 100644 --- a/agent/fw_wordpress.c +++ b/agent/fw_wordpress.c @@ -682,16 +682,6 @@ NR_PHP_WRAPPER(nr_wordpress_handle_tag_stack_after) { } NR_PHP_WRAPPER_END -NR_PHP_WRAPPER(nr_wordpress_handle_tag_stack_clean) { - NR_UNUSED_SPECIALFN; - NR_UNUSED_FUNC_RETURN_VALUE; - (void)wraprec; - if (0 != NRINI(wordpress_hooks)) { - clean_wordpress_tag_stack(auto_segment); - } -} -NR_PHP_WRAPPER_END - NR_PHP_WRAPPER(nr_wordpress_apply_filters_after) { /* using nr_php_get_user_func_arg() so that we don't perform another copy * when all we want to do is check the string length */ @@ -763,8 +753,8 @@ NR_PHP_WRAPPER(nr_wordpress_add_filter) { if (NULL != wordpress_plugin_theme || NRPRG(wordpress_core)) { #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA - callback_wraprec = nr_php_wrap_callable_before_after_clean( - zf, NULL, nr_wordpress_wrap_hook, nr_wordpress_wrap_hook); + callback_wraprec = nr_php_wrap_callable_before_after( + zf, NULL, nr_wordpress_wrap_hook); #else callback_wraprec = nr_php_wrap_callable(zf, nr_wordpress_wrap_hook); #endif @@ -823,22 +813,22 @@ void nr_wordpress_version() { void nr_wordpress_enable(TSRMLS_D) { #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_php_wrap_user_function_before_after( NR_PSTR("apply_filters"), nr_wordpress_apply_filters, - nr_wordpress_apply_filters_after, nr_wordpress_handle_tag_stack_clean); + nr_wordpress_apply_filters_after); if (0 != NRINI(wordpress_hooks)) { - nr_php_wrap_user_function_before_after_clean( + nr_php_wrap_user_function_before_after( NR_PSTR("apply_filters_ref_array"), nr_wordpress_exec_handle_tag, - nr_wordpress_handle_tag_stack_after, nr_wordpress_handle_tag_stack_clean); + nr_wordpress_handle_tag_stack_after); - nr_php_wrap_user_function_before_after_clean( + nr_php_wrap_user_function_before_after( NR_PSTR("do_action"), nr_wordpress_exec_handle_tag, - nr_wordpress_handle_tag_stack_after, nr_wordpress_handle_tag_stack_clean); + nr_wordpress_handle_tag_stack_after); - nr_php_wrap_user_function_before_after_clean( + nr_php_wrap_user_function_before_after( NR_PSTR("do_action_ref_array"), nr_wordpress_exec_handle_tag, - nr_wordpress_handle_tag_stack_after, nr_wordpress_handle_tag_stack_clean); + nr_wordpress_handle_tag_stack_after); if (0 != NRPRG(wordpress_plugins)) { nr_php_wrap_user_function(NR_PSTR("add_filter"), nr_wordpress_add_filter); } diff --git a/agent/fw_yii.c b/agent/fw_yii.c index 74aa19335..ad51482e4 100644 --- a/agent/fw_yii.c +++ b/agent/fw_yii.c @@ -93,11 +93,10 @@ void nr_yii1_enable(TSRMLS_D) { #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("CAction::runWithParams"), nr_yii1_runWithParams_wrapper, NULL, - NULL); + NR_PSTR("CAction::runWithParams"), nr_yii1_runWithParams_wrapper, NULL); nr_php_wrap_user_function_before_after_clean( NR_PSTR("CInlineAction::runWithParams"), nr_yii1_runWithParams_wrapper, - NULL, NULL); + NULL); #else nr_php_wrap_user_function(NR_PSTR("CAction::runWithParams"), nr_yii1_runWithParams_wrapper TSRMLS_CC); diff --git a/agent/lib_doctrine2.c b/agent/lib_doctrine2.c index e767d253f..5dd93aff6 100644 --- a/agent/lib_doctrine2.c +++ b/agent/lib_doctrine2.c @@ -61,12 +61,6 @@ NR_PHP_WRAPPER_END #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA -NR_PHP_WRAPPER(nr_doctrine2_cache_dql_clean) { - (void)wraprec; - nr_free(NRPRG(doctrine_dql)); -} -NR_PHP_WRAPPER_END - NR_PHP_WRAPPER(nr_doctrine2_cache_dql_after) { (void)wraprec; nr_free(NRPRG(doctrine_dql)); @@ -97,9 +91,9 @@ nr_slowsqls_labelled_query_t* nr_doctrine2_lookup_input_query(TSRMLS_D) { void nr_doctrine2_enable(TSRMLS_D) { #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_php_wrap_user_function_before_after( NR_PSTR("Doctrine\\ORM\\Query::_doExecute"), nr_doctrine2_cache_dql, - nr_doctrine2_cache_dql_after, nr_doctrine2_cache_dql_clean); + nr_doctrine2_cache_dql_after); #else nr_php_wrap_user_function(NR_PSTR("Doctrine\\ORM\\Query::_doExecute"), nr_doctrine2_cache_dql TSRMLS_CC); diff --git a/agent/lib_predis.c b/agent/lib_predis.c index 862649d3b..607142ee8 100644 --- a/agent/lib_predis.c +++ b/agent/lib_predis.c @@ -753,12 +753,6 @@ NR_PHP_WRAPPER(nr_predis_pipeline_executePipeline_after) { } NR_PHP_WRAPPER_END -NR_PHP_WRAPPER(nr_predis_pipeline_executePipeline_clean) { - (void)wraprec; - predis_executePipeline_handle_stack(); -} -NR_PHP_WRAPPER_END - NR_PHP_WRAPPER(nr_predis_webdisconnection_executeCommand_before) { (void)wraprec; @@ -844,34 +838,29 @@ void nr_predis_enable(TSRMLS_D) { */ #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_php_wrap_user_function_before_after( NR_PSTR("Predis\\Pipeline\\Pipeline::executePipeline"), nr_predis_pipeline_executePipeline, - nr_predis_pipeline_executePipeline_after, - nr_predis_pipeline_executePipeline_clean); - nr_php_wrap_user_function_before_after_clean( + nr_predis_pipeline_executePipeline_after); + nr_php_wrap_user_function_before_after( NR_PSTR("Predis\\Pipeline\\Atomic::executePipeline"), nr_predis_pipeline_executePipeline, - nr_predis_pipeline_executePipeline_after, - nr_predis_pipeline_executePipeline_clean); - nr_php_wrap_user_function_before_after_clean( + nr_predis_pipeline_executePipeline_after); + nr_php_wrap_user_function_before_after( NR_PSTR("Predis\\Pipeline\\ConnectionErrorProof::executePipeline"), nr_predis_pipeline_executePipeline, - nr_predis_pipeline_executePipeline_after, - nr_predis_pipeline_executePipeline_clean); - nr_php_wrap_user_function_before_after_clean( + nr_predis_pipeline_executePipeline_after); + nr_php_wrap_user_function_before_after( NR_PSTR("Predis\\Pipeline\\FireAndForget::executePipeline"), nr_predis_pipeline_executePipeline, - nr_predis_pipeline_executePipeline_after, - nr_predis_pipeline_executePipeline_clean); + nr_predis_pipeline_executePipeline_after); /* * Instrument Webdis connections, since they don't use the same * writeRequest()/readResponse() pair as the other connection types. */ - nr_php_wrap_user_function_before_after_clean( + nr_php_wrap_user_function_before_after( NR_PSTR("Predis\\Connection\\WebdisConnection::executeCommand"), nr_predis_webdisconnection_executeCommand_before, - nr_predis_webdisconnection_executeCommand_after, nr_predis_webdisconnection_executeCommand_after); #else nr_php_wrap_user_function( diff --git a/agent/php_execute.c b/agent/php_execute.c index 341502f6c..288b5d305 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -2084,17 +2084,8 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO) { */ create_metric = wraprec->create_metric; - /* - * A NULL return value ptr means that there was an uncaught exception - * and therefore we want to call the 'clean' function type - */ - if (NULL != nr_php_get_return_value(NR_EXECUTE_ORIG_ARGS)) { - zcaught = nr_zend_call_orig_execute_special(wraprec, segment, - NR_EXECUTE_ORIG_ARGS); - } else { - zcaught = nr_zend_call_oapi_special_clean(wraprec, segment, - NR_EXECUTE_ORIG_ARGS); - } + zcaught = nr_zend_call_orig_execute_special(wraprec, segment, + NR_EXECUTE_ORIG_ARGS); if (nrunlikely(zcaught)) { zend_bailout(); } diff --git a/agent/php_newrelic.h b/agent/php_newrelic.h index e114a6464..7b44887bc 100644 --- a/agent/php_newrelic.h +++ b/agent/php_newrelic.h @@ -117,7 +117,7 @@ extern zend_module_entry newrelic_module_entry; #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA -#define NR_GET_RETURN_VALUE_PTR &func_return_value +#define NR_GET_RETURN_VALUE_PTR func_return_value ? &func_return_value : NULL #else #define NR_GET_RETURN_VALUE_PTR nr_php_get_return_value_ptr(TSRMLS_C) #endif diff --git a/agent/php_user_instrument.c b/agent/php_user_instrument.c index 65b078b71..c7fab76d0 100644 --- a/agent/php_user_instrument.c +++ b/agent/php_user_instrument.c @@ -78,22 +78,6 @@ int nr_zend_call_oapi_special_before(nruserfn_t* wraprec, return zcaught; } - -int nr_zend_call_oapi_special_clean(nruserfn_t* wraprec, - nr_segment_t* segment, - NR_EXECUTE_PROTO) { - volatile int zcaught = 0; - - if (wraprec && wraprec->special_instrumentation_clean) { - zend_try { - wraprec->special_instrumentation_clean(wraprec, segment, - NR_EXECUTE_ORIG_ARGS); - } - zend_catch { zcaught = 1; } - zend_end_try(); - } - return zcaught; -} #endif int nr_zend_call_orig_execute_special(nruserfn_t* wraprec, nr_segment_t* segment, diff --git a/agent/php_user_instrument.h b/agent/php_user_instrument.h index f71889751..15fba7bdf 100644 --- a/agent/php_user_instrument.h +++ b/agent/php_user_instrument.h @@ -72,13 +72,10 @@ typedef struct _nruserfn_t { nrspecialfn_t special_instrumentation; /* * Only used by OAPI, PHP 8+. Used to do any special instrumentation actions - * before a function is executed. special_instrumentation_clean will clean up - * any variables that were set in the before calledback but didn't get cleaned - * up when an exception circumvents the end callback. All callbacks can be - * set. Use the `nr_php_wrap_user_function_after_before_clean` to set. + * before a function is executed. All callbacks can be set using + * `nr_php_wrap_user_function_before_after`. */ nrspecialfn_t special_instrumentation_before; - nrspecialfn_t special_instrumentation_clean; nruserfn_declared_t declared_callback; @@ -213,9 +210,6 @@ extern int nr_zend_call_orig_execute_special(nruserfn_t* wraprec, extern int nr_zend_call_oapi_special_before(nruserfn_t* wraprec, nr_segment_t* segment, NR_EXECUTE_PROTO); -extern int nr_zend_call_oapi_special_clean(nruserfn_t* wraprec, - nr_segment_t* segment, - NR_EXECUTE_PROTO); #endif /* * Purpose : Destroy all user instrumentation records, freeing diff --git a/agent/php_wrapper.c b/agent/php_wrapper.c index daa01bb4f..db2f4172e 100644 --- a/agent/php_wrapper.c +++ b/agent/php_wrapper.c @@ -9,12 +9,11 @@ #include "util_logging.h" #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO -static void nr_php_wraprec_add_before_after_clean_callbacks( +static void nr_php_wraprec_add_before_after_callbacks( const char* name, size_t namelen, nruserfn_t* wraprec, nrspecialfn_t before_callback, - nrspecialfn_t after_callback, - nrspecialfn_t clean_callback) { + nrspecialfn_t after_callback) { if (NULL == wraprec) { return; } @@ -41,43 +40,29 @@ static void nr_php_wraprec_add_before_after_clean_callbacks( return; } - if (is_instrumentation_set_and_not_equal(wraprec->special_instrumentation_clean, - clean_callback)) { - nrl_verbosedebug(NRL_INSTRUMENT, - "%s: attempting to set special_instrumentation_clean " - "for %.*s, but " - "it is already set", - __func__, NRSAFELEN(namelen), NRBLANKSTR(name)); - return; - } - wraprec->special_instrumentation = after_callback; wraprec->special_instrumentation_before = before_callback; - wraprec->special_instrumentation_clean = clean_callback; } -nruserfn_t* nr_php_wrap_user_function_before_after_clean( +nruserfn_t* nr_php_wrap_user_function_before_after( const char* name, size_t namelen, nrspecialfn_t before_callback, - nrspecialfn_t after_callback, - nrspecialfn_t clean_callback) { + nrspecialfn_t after_callback) { nruserfn_t* wraprec = nr_php_add_custom_tracer_named(name, namelen); - nr_php_wraprec_add_before_after_clean_callbacks(name, namelen, wraprec, + nr_php_wraprec_add_before_after_callbacks(name, namelen, wraprec, before_callback, - after_callback, - clean_callback); + after_callback); return wraprec; } -nruserfn_t* nr_php_wrap_callable_before_after_clean( +nruserfn_t* nr_php_wrap_callable_before_after( zend_function* callable, nrspecialfn_t before_callback, - nrspecialfn_t after_callback, - nrspecialfn_t clean_callback) { + nrspecialfn_t after_callback) { char* name = NULL; /* creates a transient wraprec */ @@ -89,10 +74,9 @@ nruserfn_t* nr_php_wrap_callable_before_after_clean( if (nrl_should_print(NRL_VERBOSEDEBUG, NRL_INSTRUMENT)) { name = nr_php_function_debug_name(callable); } - nr_php_wraprec_add_before_after_clean_callbacks(name, nr_strlen(name), wraprec, + nr_php_wraprec_add_before_after_callbacks(name, nr_strlen(name), wraprec, before_callback, - after_callback, - clean_callback); + after_callback); if (nrl_should_print(NRL_VERBOSEDEBUG, NRL_INSTRUMENT) && NULL != name) { nr_free(name); } @@ -157,8 +141,8 @@ nruserfn_t* nr_php_wrap_callable(zend_function* callable, * wraprec's internals be evaluated BEFORE for the callable's. As such, * for OAPI, this creates "before" wrappers, where normally the default * is to create "after" wrappers (see nr_php_wrap_user_function). Should - * "after"/"clean" wrappers ever be desired, it is suggested to create a - * separate nr_php_wrap_generic_callable_before_after_clean() function. + * "after" wrappers ever be desired, it is suggested to create a + * separate nr_php_wrap_generic_callable_before_after() function. * * This creates a transient wraprec that does NOT produce an * "InstrumentedFunction" metric. @@ -172,7 +156,7 @@ nruserfn_t* nr_php_wrap_generic_callable(zval* callable, if (NULL != zf) { #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA - return nr_php_wrap_callable_before_after_clean(zf, callback, NULL, NULL); + return nr_php_wrap_callable_before_after(zf, callback, NULL); #else return nr_php_wrap_callable(zf, callback); #endif @@ -362,7 +346,11 @@ zval** nr_php_get_return_value_ptr(TSRMLS_D) { return NULL; } - return &EG(current_execute_data)->return_value; + if (NULL != EG(current_execute_data)->return_value) { + return &EG(current_execute_data)->return_value; + } else { + return NULL; + } #else return EG(return_value_ptr_ptr); #endif /* PHP7 */ diff --git a/agent/php_wrapper.h b/agent/php_wrapper.h index 27e0dba91..cc1f88294 100644 --- a/agent/php_wrapper.h +++ b/agent/php_wrapper.h @@ -87,12 +87,11 @@ /* * OAPI updates: - * There are now before, after, and clean callbacks. + * There are now before and after callbacks. * 1) before_callback gets called when OAPI triggers the begin function hook. * 2) after_callback gets called when OAPI triggers the end function hook. - * 3) clean_callback gets called in the case of an exception, because the - * return value will be null, so the after_callback might not function - * correctly. Use clean_callback to reset any variables or states. + * if an exception occurs, return value will be null, so the after_callback + * must check for NULL correctly. * 4) unless explicitly setting any of the above callbacks, the default * callback is set to after_callback. * @@ -138,18 +137,16 @@ * see how it works with frameworks. */ #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO -extern nruserfn_t* nr_php_wrap_user_function_before_after_clean( +extern nruserfn_t* nr_php_wrap_user_function_before_after( const char* name, size_t namelen, nrspecialfn_t before_callback, - nrspecialfn_t after_callback, - nrspecialfn_t clean_callback); + nrspecialfn_t after_callback); -extern nruserfn_t* nr_php_wrap_callable_before_after_clean( +extern nruserfn_t* nr_php_wrap_callable_before_after( zend_function* callable, nrspecialfn_t before_callback, - nrspecialfn_t after_callback, - nrspecialfn_t clean_callback); + nrspecialfn_t after_callback); #endif extern nruserfn_t* nr_php_wrap_user_function(const char* name, size_t namelen, diff --git a/agent/tests/test_php_wrapper.c b/agent/tests/test_php_wrapper.c index 975a46904..9b09cdedd 100644 --- a/agent/tests/test_php_wrapper.c +++ b/agent/tests/test_php_wrapper.c @@ -110,12 +110,12 @@ static void execute_nested_framework_calls(nrspecialfn_t one_before, #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("one"), one_before, one_after, NULL); - nr_php_wrap_user_function_before_after_clean( - NR_PSTR("two"), two_before, two_after, NULL); - nr_php_wrap_user_function_before_after_clean( - NR_PSTR("three"), three_before, three_after, NULL); + nr_php_wrap_user_function_before_after( + NR_PSTR("one"), one_before, one_after); + nr_php_wrap_user_function_before_after( + NR_PSTR("two"), two_before, two_after); + nr_php_wrap_user_function_before_after( + NR_PSTR("three"), three_before, three_after); #else /* * This will pick up whichever one isn't null. @@ -574,31 +574,31 @@ static void test_add_arg(TSRMLS_D) { #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA /* PHP 8.0+ and OAPI */ tlib_php_request_eval("function arg0_def0() { return 4; }" TSRMLS_CC); - nr_php_wrap_user_function_before_after_clean( - NR_PSTR("arg0_def0"), test_add_array, NULL, NULL TSRMLS_CC); + nr_php_wrap_user_function_before_after( + NR_PSTR("arg0_def0"), test_add_array, NULL TSRMLS_CC); tlib_php_request_eval("function arg1_def0($a) { return $a; }" TSRMLS_CC); - nr_php_wrap_user_function_before_after_clean( - NR_PSTR("arg1_def0"), test_add_array, NULL, NULL TSRMLS_CC); + nr_php_wrap_user_function_before_after( + NR_PSTR("arg1_def0"), test_add_array, NULL TSRMLS_CC); tlib_php_request_eval( "function arg0_def1($a = null) { return $a; }" TSRMLS_CC); - nr_php_wrap_user_function_before_after_clean( - NR_PSTR("arg0_def1"), test_add_array, NULL, NULL TSRMLS_CC); + nr_php_wrap_user_function_before_after( + NR_PSTR("arg0_def1"), test_add_array, NULL TSRMLS_CC); tlib_php_request_eval( "function arg1_def1($a, $b = null) { return $b; }" TSRMLS_CC); - nr_php_wrap_user_function_before_after_clean( - NR_PSTR("arg1_def1"), test_add_array, NULL, NULL TSRMLS_CC); + nr_php_wrap_user_function_before_after( + NR_PSTR("arg1_def1"), test_add_array, NULL TSRMLS_CC); tlib_php_request_eval( "function arg1_def1_2($a, $b = null) { return $b; }" TSRMLS_CC); - nr_php_wrap_user_function_before_after_clean( - NR_PSTR("arg1_def1_2"), test_add_2_arrays, NULL, NULL TSRMLS_CC); + nr_php_wrap_user_function_before_after( + NR_PSTR("arg1_def1_2"), test_add_2_arrays, NULL TSRMLS_CC); tlib_php_request_eval("function splat(...$a) { return $a[0]; }" TSRMLS_CC); - nr_php_wrap_user_function_before_after_clean( - NR_PSTR("splat"), test_add_array, NULL, NULL TSRMLS_CC); + nr_php_wrap_user_function_before_after( + NR_PSTR("splat"), test_add_array, NULL TSRMLS_CC); #else tlib_php_request_eval("function arg0_def0() { return 4; }" TSRMLS_CC); nr_php_wrap_user_function(NR_PSTR("arg0_def0"), test_add_array TSRMLS_CC); diff --git a/tests/integration/frameworks/drupal/mock_module_handler.php b/tests/integration/frameworks/drupal/mock_module_handler.php index 84d385f10..da1f2b1a6 100644 --- a/tests/integration/frameworks/drupal/mock_module_handler.php +++ b/tests/integration/frameworks/drupal/mock_module_handler.php @@ -10,6 +10,11 @@ interface ModuleHandlerInterface { public function invokeAllWith($hook_str, $callback); } class ModuleHandler implements ModuleHandlerInterface { + public function __construct(bool $except=false) { + if ($except) { + throw new Exception("Constructor told to except"); + } + } public function invokeAllWith($hook_str, $callback) { if ($hook_str == "hook_1") { $module = "module_a"; diff --git a/tests/integration/frameworks/drupal/test_invoke_all_with.php b/tests/integration/frameworks/drupal/test_invoke_all_with.php index 289d4e69a..74e448111 100644 --- a/tests/integration/frameworks/drupal/test_invoke_all_with.php +++ b/tests/integration/frameworks/drupal/test_invoke_all_with.php @@ -108,7 +108,10 @@ public function invoke(callable $hook, string $module) { // Create module handler $drupal = new Drupal(); -$handler = $drupal->moduleHandler(); +// Throw an exception during creation to test agent recovery +$handler = $drupal->moduleHandler(true); +// Create the actual handler +$handler = $drupal->moduleHandler(false); // Test lambda calback $handler->invokeAllWith("hook_1", function (callable $hook, string $module) { diff --git a/tests/integration/test_simple.php b/tests/integration/test_simple.php new file mode 100644 index 000000000..8fa700b5b --- /dev/null +++ b/tests/integration/test_simple.php @@ -0,0 +1,88 @@ + Date: Wed, 20 Mar 2024 15:20:57 -0600 Subject: [PATCH 29/44] fix: accidentally included file --- tests/integration/test_simple.php | 88 ------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 tests/integration/test_simple.php diff --git a/tests/integration/test_simple.php b/tests/integration/test_simple.php deleted file mode 100644 index 8fa700b5b..000000000 --- a/tests/integration/test_simple.php +++ /dev/null @@ -1,88 +0,0 @@ - Date: Wed, 17 Apr 2024 10:45:25 -0600 Subject: [PATCH 30/44] fix drupal dangling segment --- agent/fw_drupal.c | 27 +++++++--- .../test_bad_params_integer_headers.php | 8 --- .../test_bad_params_integer_headers.php8.php | 49 ------------------- .../drupal7/test_bad_params_null_headers.php | 8 --- .../test_bad_params_null_headers.php8.php | 49 ------------------- 5 files changed, 19 insertions(+), 122 deletions(-) delete mode 100644 tests/integration/external/drupal7/test_bad_params_integer_headers.php8.php delete mode 100644 tests/integration/external/drupal7/test_bad_params_null_headers.php8.php diff --git a/agent/fw_drupal.c b/agent/fw_drupal.c index cbb2db852..54fcd270c 100644 --- a/agent/fw_drupal.c +++ b/agent/fw_drupal.c @@ -277,6 +277,10 @@ NR_PHP_WRAPPER(nr_drupal_http_request_after) { NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_DRUPAL); + nr_segment_external_params_t external_params + = {.library = "Drupal", + .uri = NULL}; + /* * Grab the URL for the external metric, which is the first parameter in all * versions of Drupal. @@ -286,6 +290,12 @@ NR_PHP_WRAPPER(nr_drupal_http_request_after) { goto end; } + if (NULL == NR_GET_RETURN_VALUE_PTR) { + goto end; + } + + external_params.uri = nr_strndup(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)); + /* * We only want to create a metric here if this isn't a recursive call to * drupal_http_request() caused by the original call returning a redirect. @@ -293,10 +303,6 @@ NR_PHP_WRAPPER(nr_drupal_http_request_after) { * checking a counter. */ if (1 == NRPRG(drupal_http_request_depth)) { - nr_segment_external_params_t external_params - = {.library = "Drupal", - .uri = nr_strndup(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1))}; - external_params.procedure = nr_drupal_http_request_get_method(NR_EXECUTE_ORIG_ARGS); @@ -311,17 +317,22 @@ NR_PHP_WRAPPER(nr_drupal_http_request_after) { X_NEWRELIC_APP_DATA, NRP_CAT(external_params.encoded_response_header)); } + } - nr_segment_external_end(&NRPRG(drupal_http_request_segment), - &external_params); +end: + if (1 == NRPRG(drupal_http_request_depth)) { + if (external_params.uri == NULL) { + nr_segment_discard(&NRPRG(drupal_http_request_segment)); + } else { + nr_segment_external_end(&NRPRG(drupal_http_request_segment), + &external_params); + } NRPRG(drupal_http_request_segment) = NULL; nr_free(external_params.encoded_response_header); nr_free(external_params.procedure); nr_free(external_params.uri); } - -end: nr_php_arg_release(&arg1); NRPRG(drupal_http_request_depth) -= 1; } diff --git a/tests/integration/external/drupal7/test_bad_params_integer_headers.php b/tests/integration/external/drupal7/test_bad_params_integer_headers.php index 1f0aec4c8..27beebb0c 100644 --- a/tests/integration/external/drupal7/test_bad_params_integer_headers.php +++ b/tests/integration/external/drupal7/test_bad_params_integer_headers.php @@ -14,9 +14,6 @@ /*SKIPIF =")) { - die("skip: PHP >= 8.0 not supported\n"); -} */ /*EXPECT_METRICS @@ -35,11 +32,6 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/framework/Drupal/forced"}, [1, 0, 0, 0, 0, 0]], - [{"name":"External/127.0.0.1/all"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"External/all"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"External/allOther"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"External/127.0.0.1/all", - "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/external/drupal7/test_bad_params_integer_headers.php8.php b/tests/integration/external/drupal7/test_bad_params_integer_headers.php8.php deleted file mode 100644 index 36cf6b0f1..000000000 --- a/tests/integration/external/drupal7/test_bad_params_integer_headers.php8.php +++ /dev/null @@ -1,49 +0,0 @@ - 22)); diff --git a/tests/integration/external/drupal7/test_bad_params_null_headers.php b/tests/integration/external/drupal7/test_bad_params_null_headers.php index fe9463431..bfb431e9b 100644 --- a/tests/integration/external/drupal7/test_bad_params_null_headers.php +++ b/tests/integration/external/drupal7/test_bad_params_null_headers.php @@ -14,9 +14,6 @@ /*SKIPIF =")) { - die("skip: PHP >= 8.0 not supported\n"); -} */ /*EXPECT_METRICS @@ -35,11 +32,6 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/framework/Drupal/forced"}, [1, 0, 0, 0, 0, 0]], - [{"name":"External/127.0.0.1/all"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"External/all"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"External/allOther"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"External/127.0.0.1/all", - "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/external/drupal7/test_bad_params_null_headers.php8.php b/tests/integration/external/drupal7/test_bad_params_null_headers.php8.php deleted file mode 100644 index 1189821b1..000000000 --- a/tests/integration/external/drupal7/test_bad_params_null_headers.php8.php +++ /dev/null @@ -1,49 +0,0 @@ - NULL)); From e77cbc7ad9a3344e8dc038c468552e936c4235b8 Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Wed, 17 Apr 2024 10:51:06 -0600 Subject: [PATCH 31/44] fix tests --- .../test_bad_params_integer_headers.php | 8 +++ .../test_bad_params_integer_headers.php8.php | 50 +++++++++++++++++++ .../drupal7/test_bad_params_null_headers.php | 8 +++ .../test_bad_params_null_headers.php8.php | 50 +++++++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 tests/integration/external/drupal7/test_bad_params_integer_headers.php8.php create mode 100644 tests/integration/external/drupal7/test_bad_params_null_headers.php8.php diff --git a/tests/integration/external/drupal7/test_bad_params_integer_headers.php b/tests/integration/external/drupal7/test_bad_params_integer_headers.php index 27beebb0c..1f0aec4c8 100644 --- a/tests/integration/external/drupal7/test_bad_params_integer_headers.php +++ b/tests/integration/external/drupal7/test_bad_params_integer_headers.php @@ -14,6 +14,9 @@ /*SKIPIF =")) { + die("skip: PHP >= 8.0 not supported\n"); +} */ /*EXPECT_METRICS @@ -32,6 +35,11 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/framework/Drupal/forced"}, [1, 0, 0, 0, 0, 0]], + [{"name":"External/127.0.0.1/all"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"External/all"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"External/allOther"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"External/127.0.0.1/all", + "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/external/drupal7/test_bad_params_integer_headers.php8.php b/tests/integration/external/drupal7/test_bad_params_integer_headers.php8.php new file mode 100644 index 000000000..f1fba9355 --- /dev/null +++ b/tests/integration/external/drupal7/test_bad_params_integer_headers.php8.php @@ -0,0 +1,50 @@ + 22)); diff --git a/tests/integration/external/drupal7/test_bad_params_null_headers.php b/tests/integration/external/drupal7/test_bad_params_null_headers.php index bfb431e9b..fe9463431 100644 --- a/tests/integration/external/drupal7/test_bad_params_null_headers.php +++ b/tests/integration/external/drupal7/test_bad_params_null_headers.php @@ -14,6 +14,9 @@ /*SKIPIF =")) { + die("skip: PHP >= 8.0 not supported\n"); +} */ /*EXPECT_METRICS @@ -32,6 +35,11 @@ [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/framework/Drupal/forced"}, [1, 0, 0, 0, 0, 0]], + [{"name":"External/127.0.0.1/all"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"External/all"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"External/allOther"}, [1, "??", "??", "??", "??", "??"]], + [{"name":"External/127.0.0.1/all", + "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], [{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] ] ] diff --git a/tests/integration/external/drupal7/test_bad_params_null_headers.php8.php b/tests/integration/external/drupal7/test_bad_params_null_headers.php8.php new file mode 100644 index 000000000..9cde3d021 --- /dev/null +++ b/tests/integration/external/drupal7/test_bad_params_null_headers.php8.php @@ -0,0 +1,50 @@ + NULL)); From 69531cb87855b0de381754b900e18ea23ca514ba Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Wed, 17 Apr 2024 11:25:09 -0600 Subject: [PATCH 32/44] fix tests --- .../drupal/test_module_invoke_all.php | 3 - .../drupal/test_module_invoke_all.php8.php | 91 ------------------- 2 files changed, 94 deletions(-) delete mode 100644 tests/integration/frameworks/drupal/test_module_invoke_all.php8.php diff --git a/tests/integration/frameworks/drupal/test_module_invoke_all.php b/tests/integration/frameworks/drupal/test_module_invoke_all.php index c9b70e1cf..45ca084c8 100644 --- a/tests/integration/frameworks/drupal/test_module_invoke_all.php +++ b/tests/integration/frameworks/drupal/test_module_invoke_all.php @@ -15,9 +15,6 @@ /*SKIPIF =")) { - die("skip: PHP >= 8.0 uses other test\n"); -} */ /*EXPECT diff --git a/tests/integration/frameworks/drupal/test_module_invoke_all.php8.php b/tests/integration/frameworks/drupal/test_module_invoke_all.php8.php deleted file mode 100644 index fc694e039..000000000 --- a/tests/integration/frameworks/drupal/test_module_invoke_all.php8.php +++ /dev/null @@ -1,91 +0,0 @@ - Date: Tue, 30 Apr 2024 11:48:38 -0600 Subject: [PATCH 33/44] initial commit --- .gitignore | 3 +- agent/fw_drupal.c | 4 + agent/fw_drupal_common.c | 1 + agent/fw_wordpress.c | 68 ++++++- agent/lib_predis.c | 4 + agent/php_execute.c | 179 +++++++++++++++++- agent/php_observer.c | 39 ++++ agent/php_observer.h | 14 ++ agent/php_user_instrument.c | 69 ++++++- agent/php_user_instrument.h | 5 + agent/php_wrapper.c | 29 +++ agent/php_wrapper.h | 64 ++++++- axiom/nr_segment.h | 5 +- daemon/cmd/integration_runner/main.go | 2 +- .../test_span_events_max_samples_stored1.php | 2 +- .../span_events/test_span_events_on_dt_on.php | 3 + 16 files changed, 471 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index d850b2fd0..aec099e8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Build artifacts -agent/configure.ac agent/newrelic.map +agent/configure.ac agent/*.dep axiom/tests/*.tmp bin/ @@ -13,3 +13,4 @@ php_agent.log # Dev artifacts .vscode +*.log diff --git a/agent/fw_drupal.c b/agent/fw_drupal.c index 54fcd270c..ad915e85c 100644 --- a/agent/fw_drupal.c +++ b/agent/fw_drupal.c @@ -265,7 +265,11 @@ NR_PHP_WRAPPER(nr_drupal_http_request_before) { * fcall_end is able to properly dispatch to the after wrapper, as * this new segment is now at the top of the segment stack. */ +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO NRPRG(drupal_http_request_segment)->wraprec = auto_segment->wraprec; +#else + NRPRG(drupal_http_request_segment)->execute_data = auto_segment->execute_data; +#endif } } NR_PHP_WRAPPER_END diff --git a/agent/fw_drupal_common.c b/agent/fw_drupal_common.c index 894ff2270..5fe24f5e3 100644 --- a/agent/fw_drupal_common.c +++ b/agent/fw_drupal_common.c @@ -60,6 +60,7 @@ NR_PHP_WRAPPER(nr_drupal_wrap_module_hook) { * function such as a_b_c is ambiguous (is the module a or a_b?). Instead, * we'll see if they're defined in the wraprec. */ + wraprec = nr_php_get_wraprec(execute_data->func); if ((NULL != wraprec->drupal_hook) && (NULL != wraprec->drupal_module)) { nr_drupal_create_metric(auto_segment, NR_PSTR(NR_DRUPAL_MODULE_PREFIX), wraprec->drupal_module, wraprec->drupal_module_len); diff --git a/agent/fw_wordpress.c b/agent/fw_wordpress.c index b80b07fd2..02b4268e9 100644 --- a/agent/fw_wordpress.c +++ b/agent/fw_wordpress.c @@ -329,6 +329,60 @@ static char* nr_wordpress_plugin_from_function(zend_function* func TSRMLS_DC) { return plugin; } +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +NR_PHP_WRAPPER(nr_wordpress_wrap_hook_core) { + NR_UNUSED_SPECIALFN; + (void)wraprec; + + /* + * We only want to hook the function being called if this is a WordPress + * function, we're instrumenting hooks, and WordPress is currently executing + * hooks (denoted by the wordpress_tag being set). + */ + NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_WORDPRESS); + + char* tag = nr_stack_get_top(&NRPRG(wordpress_tags)); + if ((0 == NRINI(wordpress_hooks)) || (NULL == tag)) { + NR_PHP_WRAPPER_LEAVE; + } + + NR_PHP_WRAPPER_CALL; + if (NRPRG(wordpress_core)) { + nr_wordpress_create_metric(auto_segment, NR_WORDPRESS_HOOK_PREFIX, tag); + } +} +NR_PHP_WRAPPER_END + +NR_PHP_WRAPPER(nr_wordpress_wrap_hook_plugin) { + char* plugin = NULL; + + NR_UNUSED_SPECIALFN; + (void)wraprec; + + /* + * We only want to hook the function being called if this is a WordPress + * function, we're instrumenting hooks, and WordPress is currently executing + * hooks (denoted by the wordpress_tag being set). + */ + NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_WORDPRESS); + + char* tag = nr_stack_get_top(&NRPRG(wordpress_tags)); + if ((0 == NRINI(wordpress_hooks)) || (NULL == tag)) { + NR_PHP_WRAPPER_LEAVE; + } + plugin = nr_wordpress_plugin_from_function(execute_data->func); + + NR_PHP_WRAPPER_CALL; + if (NULL != plugin) { + nr_wordpress_create_metric(auto_segment, NR_WORDPRESS_HOOK_PREFIX, tag); + nr_wordpress_create_metric(auto_segment, NR_WORDPRESS_PLUGIN_PREFIX, + plugin); + } +} +NR_PHP_WRAPPER_END +#endif + +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO NR_PHP_WRAPPER(nr_wordpress_wrap_hook) { #if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO zend_function* func = NULL; @@ -375,6 +429,7 @@ NR_PHP_WRAPPER(nr_wordpress_wrap_hook) { } } NR_PHP_WRAPPER_END +#endif // = ZEND_8_0_X_API_NO \ +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + if (NULL != wordpress_plugin_theme) { + callback_wraprec = nr_php_wrap_callable_before_after( + zf, NULL, nr_wordpress_wrap_hook_plugin); + } else { + callback_wraprec = nr_php_wrap_callable_before_after( + zf, NULL, nr_wordpress_wrap_hook_core); + } +#elif ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA callback_wraprec = nr_php_wrap_callable_before_after( zf, NULL, nr_wordpress_wrap_hook); diff --git a/agent/lib_predis.c b/agent/lib_predis.c index 607142ee8..e8c38a6d0 100644 --- a/agent/lib_predis.c +++ b/agent/lib_predis.c @@ -758,7 +758,11 @@ NR_PHP_WRAPPER(nr_predis_webdisconnection_executeCommand_before) { nr_segment_t* segment = NULL; segment = nr_segment_start(NRPRG(txn), NULL, NULL); +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + segment->execute_data = auto_segment->execute_data; +#else segment->wraprec = auto_segment->wraprec; +#endif } NR_PHP_WRAPPER_END diff --git a/agent/php_execute.c b/agent/php_execute.c index 288b5d305..289f91b8c 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -1900,9 +1900,11 @@ static void nr_php_observer_attempt_call_cufa_handler(NR_EXECUTE_PROTO) { static void nr_php_instrument_func_begin(NR_EXECUTE_PROTO) { nr_segment_t* segment = NULL; - nruserfn_t* wraprec = NULL; +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO nrtime_t txn_start_time = 0; + nruserfn_t* wraprec = NULL; int zcaught = 0; +#endif NR_UNUSED_FUNC_RETURN_VALUE; if (NULL == NRPRG(txn)) { @@ -1910,7 +1912,9 @@ static void nr_php_instrument_func_begin(NR_EXECUTE_PROTO) { } NRTXNGLOBAL(execute_count) += 1; +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO txn_start_time = nr_txn_start_time(NRPRG(txn)); +#endif /* * Handle here, but be aware the classes might not be loaded yet. */ @@ -1934,15 +1938,21 @@ static void nr_php_instrument_func_begin(NR_EXECUTE_PROTO) { */ nr_php_observer_attempt_call_cufa_handler(NR_EXECUTE_ORIG_ARGS); } +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO wraprec = nr_php_get_wraprec(execute_data->func); +#endif segment = nr_segment_start(NRPRG(txn), NULL, NULL); +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + segment->execute_data = execute_data; +#endif if (nrunlikely(NULL == segment)) { nrl_verbosedebug(NRL_AGENT, "Error starting segment."); return; } +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO if (NULL == wraprec) { return; } @@ -1988,16 +1998,64 @@ static void nr_php_instrument_func_begin(NR_EXECUTE_PROTO) { * Check for, and handle, frameworks. */ if (wraprec->is_names_wt_simple) { - nr_txn_name_from_function(NRPRG(txn), wraprec->funcname, - wraprec->classname); + + nr_txn_name_from_function(NRPRG(txn), + nr_php_op_array_function_name(NR_OP_ARRAY); + nr_php_class_entry_name(NR_OP_ARRAY->scope)); + } +#endif +} + +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time) { + /* + * During nr_zend_call_oapi_special_before, the transaction may have been + * ended and/or a new transaction may have started. To detect this, we + * compare the currently active transaction's start time with the transaction + * start time we saved before. + * + * Just comparing the transaction pointer is not enough, as a newly + * started transaction might actually obtain the same address as a + * transaction freed before. + */ + if (nrunlikely(nr_txn_start_time(NRPRG(txn)) != txn_start_time)) { + nrl_verbosedebug(NRL_AGENT, + "%s txn ended and/or started while in a wrapped function", + __func__); + + return; + } + + if (NR_OP_ARRAY->scope) { + nr_txn_force_single_count(NRPRG(txn), nr_txn_create_fn_supportability_metric( + nr_php_op_array_function_name(NR_OP_ARRAY), + nr_php_class_entry_name(NR_OP_ARRAY->scope))); + } else { + nr_txn_force_single_count(NRPRG(txn), nr_txn_create_fn_supportability_metric( + nr_php_op_array_function_name(NR_OP_ARRAY), + NULL)); } + /* + * Check for, and handle, frameworks. + */ + //if (wraprec->is_names_wt_simple) { + + // nr_txn_name_from_function(NRPRG(txn), + // nr_php_op_array_function_name(NR_OP_ARRAY), + // nr_php_class_entry_name(NR_OP_ARRAY->scope)); + //} } +#endif +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO static void nr_php_instrument_func_end(NR_EXECUTE_PROTO) { int zcaught = 0; - nr_segment_t* segment = NULL; nruserfn_t* wraprec = NULL; bool create_metric = false; +#else +static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric) { +#endif + nr_segment_t* segment = NULL; nr_php_execute_metadata_t metadata = {0}; nrtime_t txn_start_time = 0; @@ -2033,6 +2091,7 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO) { return; } +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO wraprec = segment->wraprec; if (segment->is_exception_handler) { @@ -2050,6 +2109,9 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO) { NRPRG(txn), exception, nr_php_error_get_priority(E_ERROR), false, "Uncaught exception ", &NRPRG(exception_filters) TSRMLS_CC); } else if (NULL == nr_php_get_return_value(NR_EXECUTE_ORIG_ARGS)) { +#else + if (NULL == nr_php_get_return_value(NR_EXECUTE_ORIG_ARGS)) { +#endif /* * Having no return value (and not being an exception handler) indicates * that this segment had an uncaught exception. We want to add that @@ -2066,7 +2128,6 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO) { __func__); } } - /* * Stop the segment time now so we don't add our additional processing on to * the segment's time. @@ -2078,6 +2139,7 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO) { * has specifically requested it. */ +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO if (NULL != wraprec) { /* * This is the case for specifically requested custom instrumentation. @@ -2097,6 +2159,7 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO) { nr_segment_discard(&segment); return; } +#endif /* * During nr_zend_call_orig_execute_special, the transaction may have been * ended and/or a new transaction may have started. To detect this, we @@ -2136,6 +2199,52 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) { * nr_php_execute_show */ zval* func_return_value = NULL; + //if (execute_data->func && execute_data->func->common.function_name) { + // printf("BEGIN %s\n", ZSTR_VAL(execute_data->func->common.function_name)); + //} + if (nrunlikely(NULL == execute_data)) { + return; + } + + NRPRG(php_cur_stack_depth) += 1; + + if ((0 < ((int)NRINI(max_nesting_level))) + && (NRPRG(php_cur_stack_depth) >= (int)NRINI(max_nesting_level))) { + nr_php_max_nesting_level_reached(); + } + + if (nrunlikely(0 == nr_php_recording())) { + return; + } + + int show_executes = NR_PHP_PROCESS_GLOBALS(special_flags).show_executes; + + if (nrunlikely(show_executes)) { + nrl_verbosedebug(NRL_AGENT, + "Stack depth: %d after OAPI function beginning via %s", + NRPRG(php_cur_stack_depth), __func__); + nr_php_show_exec(NR_EXECUTE_ORIG_ARGS); + } + if (NULL == NRPRG(txn)) { + return; + } + nr_php_instrument_func_begin(NR_EXECUTE_ORIG_ARGS); + + return; +} + +void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) { + /* + * Instrument the function. + * This and any other needed helper functions will replace: + * nr_php_execute_enabled + * nr_php_execute + * nr_php_execute_show + */ + zval* func_return_value = NULL; + //if (execute_data->func && execute_data->func->common.function_name) { + // printf("BEGIN %s\n", ZSTR_VAL(execute_data->func->common.function_name)); + //} if (nrunlikely(NULL == execute_data)) { return; } @@ -2159,7 +2268,11 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) { NRPRG(php_cur_stack_depth), __func__); nr_php_show_exec(NR_EXECUTE_ORIG_ARGS); } + if (NULL == NRPRG(txn)) { + return; + } nr_php_instrument_func_begin(NR_EXECUTE_ORIG_ARGS); + nr_php_observer_fcall_begin_late(execute_data, nr_txn_start_time(NRPRG(txn))); return; } @@ -2176,6 +2289,59 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data, if (nrunlikely(NULL == execute_data)) { return; } + //if (execute_data->func && execute_data->func->common.function_name) { + // printf("END %s\n", ZSTR_VAL(execute_data->func->common.function_name)); + //} + + if (nrlikely(1 == nr_php_recording())) { + int show_executes_return + = NR_PHP_PROCESS_GLOBALS(special_flags).show_execute_returns; + + if (nrunlikely(show_executes_return)) { + nrl_verbosedebug(NRL_AGENT, + "Stack depth: %d before OAPI function exiting via %s", + NRPRG(php_cur_stack_depth), __func__); + nr_php_show_exec_return(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); + } + + nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS, false); + } + + NRPRG(php_cur_stack_depth) -= 1; + + return; +} + +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +// These empty functions (rather than NULL) are used to know if instrumentation +// has been added This is needed because the process for adding instrumentation +// with a transient wrapper differs depending on if the function has been +// previously called. These will only be used when tt_detail is 0. +void nr_php_observer_empty_fcall_begin(zend_execute_data* execute_data) { + (void)execute_data; +} + +void nr_php_observer_empty_fcall_end(zend_execute_data* execute_data, + zval* func_return_value) { + (void)execute_data; + (void)func_return_value; +} + +void nr_php_observer_fcall_end_create_metric(zend_execute_data* execute_data, + zval* func_return_value) { + /* + * Instrument the function. + * This and any other needed helper functions will replace: + * nr_php_execute_enabled + * nr_php_execute + * nr_php_execute_show + */ + if (nrunlikely(NULL == execute_data)) { + return; + } + //if (execute_data->func && execute_data->func->common.function_name) { + // printf("END %s\n", ZSTR_VAL(execute_data->func->common.function_name)); + //} if (nrlikely(1 == nr_php_recording())) { int show_executes_return @@ -2188,12 +2354,13 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data, nr_php_show_exec_return(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); } - nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS); + nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS, true); } NRPRG(php_cur_stack_depth) -= 1; return; } +#endif #endif diff --git a/agent/php_observer.c b/agent/php_observer.c index 5719be38e..50ebbad26 100644 --- a/agent/php_observer.c +++ b/agent/php_observer.c @@ -72,6 +72,7 @@ /* * Register the begin and end function handlers with the Observer API. */ +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO /* PHP8+ */ static zend_observer_fcall_handlers nr_php_fcall_register_handlers( zend_execute_data* execute_data) { zend_observer_fcall_handlers handlers = {NULL, NULL}; @@ -86,6 +87,44 @@ static zend_observer_fcall_handlers nr_php_fcall_register_handlers( handlers.end = nr_php_observer_fcall_end; return handlers; } +#else +static zend_observer_fcall_handlers nr_php_fcall_register_handlers( + zend_execute_data* execute_data) { + zend_observer_fcall_handlers handlers = {NULL, NULL}; + nruserfn_t* wraprec = NULL; + if (NULL == execute_data) { + return handlers; + } + if ((NULL == execute_data->func) + || (ZEND_INTERNAL_FUNCTION == execute_data->func->type)) { + return handlers; + } + //if (execute_data->func && execute_data->func->common.function_name) { + // printf("REGISTER %s\n", ZSTR_VAL(execute_data->func->common.function_name)); + //} + wraprec = nr_php_get_wraprec(execute_data->func); + if (wraprec == NULL) { + if (0 == NRINI(tt_detail)) { + handlers.begin = nr_php_observer_empty_fcall_begin; + handlers.end = nr_php_observer_empty_fcall_end; + return handlers; + } else { + handlers.begin = nr_php_observer_fcall_begin; + handlers.end = nr_php_observer_fcall_end; + return handlers; + } + } + handlers.begin = wraprec->special_instrumentation_before ? + (zend_observer_fcall_begin_handler)wraprec->special_instrumentation_before : + nr_php_observer_fcall_begin_instrumented; + handlers.end = wraprec->special_instrumentation ? + (zend_observer_fcall_end_handler)wraprec->special_instrumentation : + wraprec->create_metric ? nr_php_observer_fcall_end_create_metric: + nr_php_observer_fcall_end; + return handlers; +} +#endif + void nr_php_observer_no_op(zend_execute_data* execute_data NRUNUSED){}; diff --git a/agent/php_observer.h b/agent/php_observer.h index 6a80873cb..69dbeb315 100644 --- a/agent/php_observer.h +++ b/agent/php_observer.h @@ -76,6 +76,20 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data, zval* func_return_value); +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +// These empty functions (rather than NULL) are used to know if instrumentation +// has been added This is needed because the process for adding instrumentation +// with a transient wrapper differs depending on if the function has been +// previously called. These will only be used when tt_detail is 0. +void nr_php_observer_empty_fcall_begin(zend_execute_data* execute_data); +void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data); + +void nr_php_observer_empty_fcall_end(zend_execute_data* execute_data, + zval* func_return_value); +void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time); +void nr_php_observer_fcall_end_create_metric(zend_execute_data* execute_data, + zval* func_return_value); +#endif /* PHP 8.2+ */ #endif /* PHP8+ */ #endif // NEWRELIC_PHP_AGENT_PHP_OBSERVER_H diff --git a/agent/php_user_instrument.c b/agent/php_user_instrument.c index c7fab76d0..8ee97004c 100644 --- a/agent/php_user_instrument.c +++ b/agent/php_user_instrument.c @@ -62,6 +62,24 @@ int nr_zend_call_orig_execute(NR_EXECUTE_PROTO TSRMLS_DC) { return zcaught; } #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO /* PHP8+ */ +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO /* PHP8+ */ +int nr_zend_call_oapi_special_before(nruserfn_t* wraprec, + nr_segment_t* segment, + NR_EXECUTE_PROTO) { + volatile int zcaught = 0; + (void)segment; + + if (wraprec && wraprec->special_instrumentation_before) { + zend_try { + wraprec->special_instrumentation_before(NR_EXECUTE_ORIG_ARGS); + } + zend_catch { zcaught = 1; } + zend_end_try(); + } + + return zcaught; +} +#else int nr_zend_call_oapi_special_before(nruserfn_t* wraprec, nr_segment_t* segment, NR_EXECUTE_PROTO) { @@ -79,15 +97,23 @@ int nr_zend_call_oapi_special_before(nruserfn_t* wraprec, return zcaught; } #endif +#endif int nr_zend_call_orig_execute_special(nruserfn_t* wraprec, nr_segment_t* segment, NR_EXECUTE_PROTO TSRMLS_DC) { +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO /* PHP8+ */ + (void)segment; +#endif volatile int zcaught = 0; NR_UNUSED_FUNC_RETURN_VALUE; zend_try { if (wraprec && wraprec->special_instrumentation) { +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO /* PHP8+ */ + wraprec->special_instrumentation(NR_EXECUTE_ORIG_ARGS); +#else wraprec->special_instrumentation(wraprec, segment, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); +#endif } else { NR_PHP_PROCESS_GLOBALS(orig_execute) (NR_EXECUTE_ORIG_ARGS_OVERWRITE TSRMLS_CC); @@ -228,21 +254,21 @@ static void nr_php_wrap_zend_function(zend_function* func, } } -static void nr_php_wrap_user_function_internal(nruserfn_t* wraprec TSRMLS_DC) { +static zend_function* nr_php_wrap_user_function_internal(nruserfn_t* wraprec TSRMLS_DC) { zend_function* orig_func = 0; if (0 == NR_PHP_PROCESS_GLOBALS(done_instrumentation)) { - return; + return NULL; } if (wraprec->is_wrapped) { - return; + return NULL; } #if ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO \ && defined OVERWRITE_ZEND_EXECUTE_DATA /* PHP8+ */ if (nrunlikely(-1 == NR_PHP_PROCESS_GLOBALS(zend_offset))) { - return; + return NULL; } #endif if (0 == wraprec->classname) { @@ -256,7 +282,7 @@ static void nr_php_wrap_user_function_internal(nruserfn_t* wraprec TSRMLS_DC) { if (NULL == orig_func) { /* It could be in a file not yet loaded, no reason to log anything. */ - return; + return NULL; } if (ZEND_USER_FUNCTION != orig_func->type) { @@ -269,9 +295,10 @@ static void nr_php_wrap_user_function_internal(nruserfn_t* wraprec TSRMLS_DC) { * logs with this message. */ wraprec->is_disabled = 1; - return; + return NULL; } nr_php_wrap_zend_function(orig_func, wraprec TSRMLS_CC); + return orig_func; } static nruserfn_t* nr_php_user_wraprec_create(void) { @@ -423,6 +450,10 @@ nruserfn_t* nr_php_add_custom_tracer_named(const char* namestr, size_t namestrlen) { nruserfn_t* wraprec; nruserfn_t* p; + zend_function* orig_func; +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + zend_observer_fcall_begin_handler *begin_handler; +#endif wraprec = nr_php_user_wraprec_create_named(namestr, namestrlen); if (0 == wraprec) { @@ -452,12 +483,36 @@ nruserfn_t* nr_php_add_custom_tracer_named(const char* namestr, NRP_PHP(wraprec->classname), (0 == wraprec->classname) ? "" : "::", NRP_PHP(wraprec->funcname)); - nr_php_wrap_user_function_internal(wraprec TSRMLS_CC); + orig_func = nr_php_wrap_user_function_internal(wraprec TSRMLS_CC); /* non-transient wraprecs are added to both the hashmap and linked list. * At request shutdown, the hashmap will free transients, but leave * non-transients to be freed when the linked list is disposed of which is at * module shutdown */ nr_php_add_custom_tracer_common(wraprec); +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + if (orig_func) { + // Before messing with our handlers, we must ensure that the observer fields of the function are initialized + begin_handler = (zend_observer_fcall_begin_handler *)&ZEND_OP_ARRAY_EXTENSION((&(orig_func)->common), zend_observer_fcall_op_array_extension); + // begin_handler will be NULL if the observer hasn't been installed yet. + // *begin_Handler will be NULL if the function has not yet been called. + if (begin_handler && *begin_handler) { + if (zend_observer_remove_begin_handler(orig_func, NRINI(tt_detail) ? + nr_php_observer_fcall_begin : + nr_php_observer_empty_fcall_begin)) { + zend_observer_add_begin_handler(orig_func, wraprec->special_instrumentation_before ? + (zend_observer_fcall_begin_handler)wraprec->special_instrumentation_before : + nr_php_observer_fcall_begin_instrumented); + } + if (zend_observer_remove_end_handler(orig_func, NRINI(tt_detail) ? + nr_php_observer_fcall_end : + nr_php_observer_empty_fcall_end)) { + zend_observer_add_end_handler(orig_func, wraprec->special_instrumentation ? + (zend_observer_fcall_end_handler)wraprec->special_instrumentation : + nr_php_observer_fcall_end); + } + } + } +#endif return wraprec; /* return the new wraprec */ } diff --git a/agent/php_user_instrument.h b/agent/php_user_instrument.h index 15fba7bdf..acae87dbb 100644 --- a/agent/php_user_instrument.h +++ b/agent/php_user_instrument.h @@ -19,12 +19,17 @@ struct _nruserfn_t; * This is an unused structure that is used to ensure that a bare return won't * compile in a user wrapper. */ +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +typedef void (*nrspecialfn_t)(zend_execute_data*, ...); + +#else struct nrspecialfn_return_t { int zcaught; }; typedef struct nrspecialfn_return_t (*nrspecialfn_t)( NR_SPECIALFNPTR_PROTO TSRMLS_DC); +#endif typedef void (*nruserfn_declared_t)(TSRMLS_D); /* diff --git a/agent/php_wrapper.c b/agent/php_wrapper.c index db2f4172e..2036654b4 100644 --- a/agent/php_wrapper.c +++ b/agent/php_wrapper.c @@ -120,6 +120,9 @@ nruserfn_t* nr_php_wrap_callable(zend_function* callable, nrspecialfn_t callback TSRMLS_DC) { /* creates a transient wraprec */ nruserfn_t* wraprec = nr_php_add_custom_tracer_callable(callable TSRMLS_CC); +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + zend_observer_fcall_begin_handler *begin_handler; +#endif if (wraprec && callback) { if ((NULL != wraprec->special_instrumentation) @@ -130,6 +133,32 @@ nruserfn_t* nr_php_wrap_callable(zend_function* callable, __func__); } else { wraprec->special_instrumentation = callback; +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + if (callable) { + // Before messing with our handlers, we must ensure that the observer fields of the function are initialized + begin_handler = (zend_observer_fcall_begin_handler *)&ZEND_OP_ARRAY_EXTENSION((&(callable)->common), zend_observer_fcall_op_array_extension); + // begin_handler will be NULL if the observer hasn't been installed yet. + // *begin_Handler will be NULL if the function has not yet been called. + if (begin_handler && *begin_handler) { + // It is okay to attempt to remove a handler that doesn't exist + // TODO this could remove nr_php_observer_fcall_begin/end and then re-add it :) + if (zend_observer_remove_begin_handler(callable, NRINI(tt_detail) ? + nr_php_observer_fcall_begin : + nr_php_observer_empty_fcall_begin)) { + zend_observer_add_begin_handler(callable, wraprec->special_instrumentation_before ? + (zend_observer_fcall_begin_handler)wraprec->special_instrumentation_before : + nr_php_observer_fcall_begin); + } + if (zend_observer_remove_end_handler(callable, NRINI(tt_detail) ? + nr_php_observer_fcall_end : + nr_php_observer_empty_fcall_end)) { + zend_observer_add_end_handler(callable, wraprec->special_instrumentation ? + (zend_observer_fcall_end_handler)wraprec->special_instrumentation : + nr_php_observer_fcall_end); + } + } + } +#endif } } diff --git a/agent/php_wrapper.h b/agent/php_wrapper.h index cc1f88294..cf520d39b 100644 --- a/agent/php_wrapper.h +++ b/agent/php_wrapper.h @@ -245,9 +245,17 @@ extern void nr_php_scope_release(zval** ppzv); */ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO #define NR_PHP_WRAPPER_PROTOTYPE(name) \ struct nrspecialfn_return_t name(NR_SPECIALFNPTR_PROTO TSRMLS_DC) +#else + +#define NR_PHP_WRAPPER_PROTOTYPE(name) \ + void name(zend_execute_data* execute_data, ...) +#endif + +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO #define NR_PHP_WRAPPER_START(name) \ NR_PHP_WRAPPER_PROTOTYPE(name) { \ int was_executed = 0; \ @@ -257,14 +265,40 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); \ (void)auto_segment; // auto_segment isn't generally used in wrapper // functions +#else +#define NR_PHP_WRAPPER_START(name) \ + NR_PHP_WRAPPER_PROTOTYPE(name) { \ + int was_executed = 0; \ + int zcaught = 0; \ + bool is_begin = false; \ + nruserfn_t* wraprec = NULL; \ + zval* func_return_value = NULL; \ + zval** func_return_value_ptr = NULL; \ + const nrtxn_t* txn = NRPRG(txn); \ + const nrtime_t txn_start_time = nr_txn_start_time(txn); \ + \ + nr_segment_t* auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \ + if (!auto_segment || auto_segment->execute_data != execute_data) { \ + nr_php_observer_fcall_begin(execute_data); \ + auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \ + is_begin = true; \ + } else { \ + func_return_value_ptr = nr_php_get_return_value_ptr(); \ + func_return_value = func_return_value_ptr ? *func_return_value_ptr : NULL;\ + } +#endif #define NR_PHP_WRAPPER(name) static NR_PHP_WRAPPER_START(name) +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO #define NR_PHP_WRAPPER_END \ callback_end: \ __attribute__((unused)); \ if (!was_executed) { \ NR_PHP_WRAPPER_CALL \ + } \ + if (!is_begin) { \ + nr_php_observer_fcall_end(execute_data, func_return_value); \ } \ \ if (zcaught) { \ @@ -274,7 +308,27 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); struct nrspecialfn_return_t _retval = {zcaught}; \ return _retval; \ } \ - } +} +#else +#define NR_PHP_WRAPPER_END \ + callback_end: \ + __attribute__((unused)); \ + if (!was_executed) { \ + NR_PHP_WRAPPER_CALL \ + } \ + if (!is_begin) { \ + func_return_value_ptr = nr_php_get_return_value_ptr(); \ + nr_php_observer_fcall_end(execute_data, \ + func_return_value_ptr ? *func_return_value_ptr : NULL); \ + } else { \ + nr_php_observer_fcall_begin_late(execute_data, txn_start_time);\ + } \ + if (zcaught) { \ + zend_bailout(); \ + } \ +} +#endif + #define NR_PHP_WRAPPER_CALL \ if (!was_executed) { \ @@ -319,11 +373,19 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); } \ } while (0) +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO #define NR_PHP_WRAPPER_DELEGATE(name) \ if (!was_executed) { \ zcaught = ((name)(NR_SPECIALFNPTR_ORIG_ARGS TSRMLS_CC)).zcaught; \ was_executed = 1; \ } +#else +#define NR_PHP_WRAPPER_DELEGATE(name) \ + if (!was_executed) { \ + ((name)(execute_data)); \ + was_executed = 1; \ + } +#endif static inline bool is_instrumentation_set_and_not_equal( nrspecialfn_t instrumentation, diff --git a/axiom/nr_segment.h b/axiom/nr_segment.h index 56d972579..70fd2d3c3 100644 --- a/axiom/nr_segment.h +++ b/axiom/nr_segment.h @@ -182,7 +182,10 @@ typedef struct _nr_segment_t { external or datastore segments. */ nr_segment_error_t* error; /* segment error attributes */ -#if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + void* execute_data; + +#elif ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA /* PHP 8.0+ and OAPI */ /* diff --git a/daemon/cmd/integration_runner/main.go b/daemon/cmd/integration_runner/main.go index 40f472af4..2b4a8bbe9 100644 --- a/daemon/cmd/integration_runner/main.go +++ b/daemon/cmd/integration_runner/main.go @@ -524,7 +524,7 @@ func runTest(t *integration.Test) { if err != nil { t.Output = body - t.Fatal(fmt.Errorf("error executing skipif: %v", err)) + t.Fatal(fmt.Errorf("error executing skipif: %v %v", err, skipIf)) return } diff --git a/tests/integration/span_events/test_span_events_max_samples_stored1.php b/tests/integration/span_events/test_span_events_max_samples_stored1.php index 93807d478..e6937bab5 100644 --- a/tests/integration/span_events/test_span_events_max_samples_stored1.php +++ b/tests/integration/span_events/test_span_events_max_samples_stored1.php @@ -29,7 +29,7 @@ newrelic_add_custom_tracer('main'); function main() { - usleep(10); + usleep(1); } $sample_size = 10000; diff --git a/tests/integration/span_events/test_span_events_on_dt_on.php b/tests/integration/span_events/test_span_events_on_dt_on.php index e94a4570a..d89c0e65c 100644 --- a/tests/integration/span_events/test_span_events_on_dt_on.php +++ b/tests/integration/span_events/test_span_events_on_dt_on.php @@ -76,6 +76,9 @@ Hello */ +if (version_compare(PHP_VERSION, "7.0", "<")) { + die("skip: CLM for PHP 5 not supported\n"); +} newrelic_add_custom_tracer('main'); function main() { From a847bae895b56ba308973ebf38e44a1d612d2afb Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Wed, 1 May 2024 13:09:54 -0600 Subject: [PATCH 34/44] consistent timings --- agent/php_wrapper.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/agent/php_wrapper.h b/agent/php_wrapper.h index cf520d39b..f6da4bfa9 100644 --- a/agent/php_wrapper.h +++ b/agent/php_wrapper.h @@ -285,6 +285,8 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); } else { \ func_return_value_ptr = nr_php_get_return_value_ptr(); \ func_return_value = func_return_value_ptr ? *func_return_value_ptr : NULL;\ + nr_php_observer_fcall_end(execute_data, \ + func_return_value_ptr ? *func_return_value_ptr : NULL); \ } #endif @@ -296,9 +298,6 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); __attribute__((unused)); \ if (!was_executed) { \ NR_PHP_WRAPPER_CALL \ - } \ - if (!is_begin) { \ - nr_php_observer_fcall_end(execute_data, func_return_value); \ } \ \ if (zcaught) { \ @@ -316,11 +315,7 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); if (!was_executed) { \ NR_PHP_WRAPPER_CALL \ } \ - if (!is_begin) { \ - func_return_value_ptr = nr_php_get_return_value_ptr(); \ - nr_php_observer_fcall_end(execute_data, \ - func_return_value_ptr ? *func_return_value_ptr : NULL); \ - } else { \ + if (is_begin) { \ nr_php_observer_fcall_begin_late(execute_data, txn_start_time);\ } \ if (zcaught) { \ From f97837c1b3ade5396bf5552230de2f8b540578cd Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Thu, 2 May 2024 08:31:50 -0600 Subject: [PATCH 35/44] fixups --- agent/fw_wordpress.c | 4 ++++ agent/php_execute.c | 8 +++++++- agent/php_user_instrument.c | 6 +++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/agent/fw_wordpress.c b/agent/fw_wordpress.c index 02b4268e9..842037d16 100644 --- a/agent/fw_wordpress.c +++ b/agent/fw_wordpress.c @@ -747,7 +747,11 @@ NR_PHP_WRAPPER(nr_wordpress_apply_filters_after) { nr_wordpress_name_the_wt(tag, retval_ptr TSRMLS_CC); } +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO nr_wordpress_handle_tag_stack_after(execute_data); +#else + nr_wordpress_handle_tag_stack_after(NR_SPECIALFNPTR_ORIG_ARGS); +#endif } NR_PHP_WRAPPER_END #endif /* OAPI */ diff --git a/agent/php_execute.c b/agent/php_execute.c index 289f91b8c..fe226c0e9 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -2000,7 +2000,7 @@ static void nr_php_instrument_func_begin(NR_EXECUTE_PROTO) { if (wraprec->is_names_wt_simple) { nr_txn_name_from_function(NRPRG(txn), - nr_php_op_array_function_name(NR_OP_ARRAY); + nr_php_op_array_function_name(NR_OP_ARRAY), nr_php_class_entry_name(NR_OP_ARRAY->scope)); } #endif @@ -2233,6 +2233,7 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) { return; } +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) { /* * Instrument the function. @@ -2276,6 +2277,7 @@ void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) { return; } +#endif void nr_php_observer_fcall_end(zend_execute_data* execute_data, zval* func_return_value) { @@ -2304,7 +2306,11 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data, nr_php_show_exec_return(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); } +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS, false); +#else + nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS); +#endif } NRPRG(php_cur_stack_depth) -= 1; diff --git a/agent/php_user_instrument.c b/agent/php_user_instrument.c index 8ee97004c..62b9fb942 100644 --- a/agent/php_user_instrument.c +++ b/agent/php_user_instrument.c @@ -450,8 +450,8 @@ nruserfn_t* nr_php_add_custom_tracer_named(const char* namestr, size_t namestrlen) { nruserfn_t* wraprec; nruserfn_t* p; - zend_function* orig_func; #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + zend_function* orig_func; zend_observer_fcall_begin_handler *begin_handler; #endif @@ -483,7 +483,11 @@ nruserfn_t* nr_php_add_custom_tracer_named(const char* namestr, NRP_PHP(wraprec->classname), (0 == wraprec->classname) ? "" : "::", NRP_PHP(wraprec->funcname)); +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO orig_func = nr_php_wrap_user_function_internal(wraprec TSRMLS_CC); +#else + nr_php_wrap_user_function_internal(wraprec TSRMLS_CC); +#endif /* non-transient wraprecs are added to both the hashmap and linked list. * At request shutdown, the hashmap will free transients, but leave * non-transients to be freed when the linked list is disposed of which is at From 56233e99994b3409f28189033262a4181d7c10c6 Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Thu, 2 May 2024 08:42:37 -0600 Subject: [PATCH 36/44] fixups --- agent/fw_drupal_common.c | 2 ++ agent/fw_wordpress.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/agent/fw_drupal_common.c b/agent/fw_drupal_common.c index 5fe24f5e3..c09aac3d6 100644 --- a/agent/fw_drupal_common.c +++ b/agent/fw_drupal_common.c @@ -60,7 +60,9 @@ NR_PHP_WRAPPER(nr_drupal_wrap_module_hook) { * function such as a_b_c is ambiguous (is the module a or a_b?). Instead, * we'll see if they're defined in the wraprec. */ +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO wraprec = nr_php_get_wraprec(execute_data->func); +#endif if ((NULL != wraprec->drupal_hook) && (NULL != wraprec->drupal_module)) { nr_drupal_create_metric(auto_segment, NR_PSTR(NR_DRUPAL_MODULE_PREFIX), wraprec->drupal_module, wraprec->drupal_module_len); diff --git a/agent/fw_wordpress.c b/agent/fw_wordpress.c index 842037d16..5bd45f7c8 100644 --- a/agent/fw_wordpress.c +++ b/agent/fw_wordpress.c @@ -357,7 +357,6 @@ NR_PHP_WRAPPER(nr_wordpress_wrap_hook_plugin) { char* plugin = NULL; NR_UNUSED_SPECIALFN; - (void)wraprec; /* * We only want to hook the function being called if this is a WordPress @@ -370,7 +369,10 @@ NR_PHP_WRAPPER(nr_wordpress_wrap_hook_plugin) { if ((0 == NRINI(wordpress_hooks)) || (NULL == tag)) { NR_PHP_WRAPPER_LEAVE; } - plugin = nr_wordpress_plugin_from_function(execute_data->func); + // Use optimized wraprec hashmap over plugin hashmap + wraprec = nr_php_get_wraprec(execute_data->func); + plugin = wraprec->wordpress_plugin_theme; + //plugin = nr_wordpress_plugin_from_function(execute_data->func); NR_PHP_WRAPPER_CALL; if (NULL != plugin) { From d76b8c94fcd292a3808a2edf2f1331a2a3f1eedd Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Fri, 3 May 2024 11:57:44 -0600 Subject: [PATCH 37/44] fix instrumented function metric --- agent/php_observer.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/agent/php_observer.c b/agent/php_observer.c index 50ebbad26..cb23d566f 100644 --- a/agent/php_observer.c +++ b/agent/php_observer.c @@ -115,12 +115,15 @@ static zend_observer_fcall_handlers nr_php_fcall_register_handlers( } } handlers.begin = wraprec->special_instrumentation_before ? - (zend_observer_fcall_begin_handler)wraprec->special_instrumentation_before : - nr_php_observer_fcall_begin_instrumented; + (zend_observer_fcall_begin_handler)wraprec->special_instrumentation_before : + wraprec->is_transient ? + nr_php_observer_fcall_begin : + nr_php_observer_fcall_begin_instrumented; handlers.end = wraprec->special_instrumentation ? - (zend_observer_fcall_end_handler)wraprec->special_instrumentation : - wraprec->create_metric ? nr_php_observer_fcall_end_create_metric: - nr_php_observer_fcall_end; + (zend_observer_fcall_end_handler)wraprec->special_instrumentation : + wraprec->create_metric ? + nr_php_observer_fcall_end_create_metric : + nr_php_observer_fcall_end; return handlers; } #endif From c99b864f4fc0ac8ad3c59af3d5faa32aa0a01bbb Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Tue, 7 May 2024 09:41:53 -0600 Subject: [PATCH 38/44] fix transient wrapper creation --- agent/php_wrapper.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/agent/php_wrapper.c b/agent/php_wrapper.c index 2036654b4..9a39b42d4 100644 --- a/agent/php_wrapper.c +++ b/agent/php_wrapper.c @@ -64,6 +64,9 @@ nruserfn_t* nr_php_wrap_callable_before_after( nrspecialfn_t before_callback, nrspecialfn_t after_callback) { char* name = NULL; +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + zend_observer_fcall_begin_handler *begin_handler; +#endif /* creates a transient wraprec */ nruserfn_t* wraprec = nr_php_add_custom_tracer_callable(callable TSRMLS_CC); @@ -80,6 +83,32 @@ nruserfn_t* nr_php_wrap_callable_before_after( if (nrl_should_print(NRL_VERBOSEDEBUG, NRL_INSTRUMENT) && NULL != name) { nr_free(name); } +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO + if (callable) { + // Before messing with our handlers, we must ensure that the observer fields of the function are initialized + begin_handler = (zend_observer_fcall_begin_handler *)&ZEND_OP_ARRAY_EXTENSION((&(callable)->common), zend_observer_fcall_op_array_extension); + // begin_handler will be NULL if the observer hasn't been installed yet. + // *begin_Handler will be NULL if the function has not yet been called. + if (begin_handler && *begin_handler) { + // It is okay to attempt to remove a handler that doesn't exist + // TODO this could remove nr_php_observer_fcall_begin/end and then re-add it :) + if (zend_observer_remove_begin_handler(callable, NRINI(tt_detail) ? + nr_php_observer_fcall_begin : + nr_php_observer_empty_fcall_begin)) { + zend_observer_add_begin_handler(callable, wraprec->special_instrumentation_before ? + (zend_observer_fcall_begin_handler)wraprec->special_instrumentation_before : + nr_php_observer_fcall_begin); + } + if (zend_observer_remove_end_handler(callable, NRINI(tt_detail) ? + nr_php_observer_fcall_end : + nr_php_observer_empty_fcall_end)) { + zend_observer_add_end_handler(callable, wraprec->special_instrumentation ? + (zend_observer_fcall_end_handler)wraprec->special_instrumentation : + nr_php_observer_fcall_end); + } + } + } +#endif return wraprec; } From 41d4fc255d8d42325d14fb8ace7dc927b754a32e Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Wed, 8 May 2024 11:44:23 -0600 Subject: [PATCH 39/44] fix double segments --- agent/fw_wordpress.c | 8 ++--- agent/php_execute.c | 73 +++++++++++++++++++++++++++++++++++++++++--- agent/php_newrelic.h | 5 +++ agent/php_observer.h | 3 ++ agent/php_rinit.c | 4 +++ agent/php_wrapper.h | 14 +++++++-- 6 files changed, 94 insertions(+), 13 deletions(-) diff --git a/agent/fw_wordpress.c b/agent/fw_wordpress.c index 5bd45f7c8..5aa99114b 100644 --- a/agent/fw_wordpress.c +++ b/agent/fw_wordpress.c @@ -749,11 +749,9 @@ NR_PHP_WRAPPER(nr_wordpress_apply_filters_after) { nr_wordpress_name_the_wt(tag, retval_ptr TSRMLS_CC); } -#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO - nr_wordpress_handle_tag_stack_after(execute_data); -#else - nr_wordpress_handle_tag_stack_after(NR_SPECIALFNPTR_ORIG_ARGS); -#endif + if (0 != NRINI(wordpress_hooks)) { + clean_wordpress_tag_stack(auto_segment); + } } NR_PHP_WRAPPER_END #endif /* OAPI */ diff --git a/agent/php_execute.c b/agent/php_execute.c index fe226c0e9..90a19a400 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -2047,16 +2047,40 @@ void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t } #endif +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +void nr_php_observer_fcall_end_late(zend_execute_data* execute_data, bool create_metric, nrtime_t txn_start_time) { + nr_segment_t* segment; + nr_php_execute_metadata_t metadata = {0}; + if (nrunlikely(nr_txn_start_time(NRPRG(txn)) != txn_start_time)) { + nrl_verbosedebug(NRL_AGENT, + "%s txn ended and/or started while in a wrapped function", + __func__); + + return; + } + + /* + * Reassign segment to the current segment, as some before/after wraprecs + * start and then stop a segment. If that happened, we want to ensure we + * get the now-current segment + */ + segment = nr_txn_get_current_segment(NRPRG(txn), NULL); + nr_php_execute_metadata_init(&metadata, NR_OP_ARRAY); + nr_php_execute_segment_end(segment, &metadata, create_metric); + nr_php_execute_metadata_release(&metadata); +} +#endif + #if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO static void nr_php_instrument_func_end(NR_EXECUTE_PROTO) { int zcaught = 0; nruserfn_t* wraprec = NULL; bool create_metric = false; + nr_php_execute_metadata_t metadata = {0}; #else -static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric) { +static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, bool end_segment) { #endif nr_segment_t* segment = NULL; - nr_php_execute_metadata_t metadata = {0}; nrtime_t txn_start_time = 0; if (NULL == NRPRG(txn)) { @@ -2159,7 +2183,6 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric) { nr_segment_discard(&segment); return; } -#endif /* * During nr_zend_call_orig_execute_special, the transaction may have been * ended and/or a new transaction may have started. To detect this, we @@ -2187,6 +2210,11 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric) { nr_php_execute_metadata_init(&metadata, NR_OP_ARRAY); nr_php_execute_segment_end(segment, &metadata, create_metric); nr_php_execute_metadata_release(&metadata); +#else + if (end_segment) { + nr_php_observer_fcall_end_late(execute_data, create_metric, txn_start_time); + } +#endif return; } @@ -2307,7 +2335,7 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data, } #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO - nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS, false); + nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS, false, true); #else nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS); #endif @@ -2323,6 +2351,41 @@ void nr_php_observer_fcall_end(zend_execute_data* execute_data, // has been added This is needed because the process for adding instrumentation // with a transient wrapper differs depending on if the function has been // previously called. These will only be used when tt_detail is 0. +void nr_php_observer_fcall_end_keep_segment(zend_execute_data* execute_data, + zval* func_return_value) { + /* + * Instrument the function. + * This and any other needed helper functions will replace: + * nr_php_execute_enabled + * nr_php_execute + * nr_php_execute_show + */ + if (nrunlikely(NULL == execute_data)) { + return; + } + //if (execute_data->func && execute_data->func->common.function_name) { + // printf("END %s\n", ZSTR_VAL(execute_data->func->common.function_name)); + //} + + if (nrlikely(1 == nr_php_recording())) { + int show_executes_return + = NR_PHP_PROCESS_GLOBALS(special_flags).show_execute_returns; + + if (nrunlikely(show_executes_return)) { + nrl_verbosedebug(NRL_AGENT, + "Stack depth: %d before OAPI function exiting via %s", + NRPRG(php_cur_stack_depth), __func__); + nr_php_show_exec_return(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); + } + + nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS, false, false); + } + + NRPRG(php_cur_stack_depth) -= 1; + + return; +} + void nr_php_observer_empty_fcall_begin(zend_execute_data* execute_data) { (void)execute_data; } @@ -2360,7 +2423,7 @@ void nr_php_observer_fcall_end_create_metric(zend_execute_data* execute_data, nr_php_show_exec_return(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); } - nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS, true); + nr_php_instrument_func_end(NR_EXECUTE_ORIG_ARGS, true, true); } NRPRG(php_cur_stack_depth) -= 1; diff --git a/agent/php_newrelic.h b/agent/php_newrelic.h index 7b44887bc..8ec589937 100644 --- a/agent/php_newrelic.h +++ b/agent/php_newrelic.h @@ -450,6 +450,11 @@ int symfony1_in_dispatch; /* Whether we are currently within a int symfony1_in_error404; /* Whether we are currently within a sfError404Exception::printStackTrace() frame */ +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO \ + && !defined OVERWRITE_ZEND_EXECUTE_DATA +bool in_wrapper; +#endif + #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA bool check_cufa; diff --git a/agent/php_observer.h b/agent/php_observer.h index 69dbeb315..566a8c8fb 100644 --- a/agent/php_observer.h +++ b/agent/php_observer.h @@ -87,6 +87,9 @@ void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data); void nr_php_observer_empty_fcall_end(zend_execute_data* execute_data, zval* func_return_value); void nr_php_observer_fcall_begin_late(zend_execute_data* execute_data, nrtime_t txn_start_time); +void nr_php_observer_fcall_end_keep_segment(zend_execute_data* execute_data, + zval* func_return_value); +void nr_php_observer_fcall_end_late(zend_execute_data* execute_data, bool create_metric, nrtime_t txn_start_time); void nr_php_observer_fcall_end_create_metric(zend_execute_data* execute_data, zval* func_return_value); #endif /* PHP 8.2+ */ diff --git a/agent/php_rinit.c b/agent/php_rinit.c index d704f935e..5d8634292 100644 --- a/agent/php_rinit.c +++ b/agent/php_rinit.c @@ -126,6 +126,10 @@ PHP_RINIT_FUNCTION(newrelic) { NRPRG(predis_ctxs).dtor = str_stack_dtor; NRPRG(drupal_invoke_all_hooks).dtor = zval_stack_dtor; #endif +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO \ + && !defined OVERWRITE_ZEND_EXECUTE_DATA + NRPRG(in_wrapper) = false; +#endif NRPRG(mysql_last_conn) = NULL; NRPRG(pgsql_last_conn) = NULL; diff --git a/agent/php_wrapper.h b/agent/php_wrapper.h index f6da4bfa9..7c8aeb75d 100644 --- a/agent/php_wrapper.h +++ b/agent/php_wrapper.h @@ -276,16 +276,21 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); zval** func_return_value_ptr = NULL; \ const nrtxn_t* txn = NRPRG(txn); \ const nrtime_t txn_start_time = nr_txn_start_time(txn); \ + if (NRPRG(in_wrapper)) { \ + printf("AAHHHHHHHHHHH\n"); \ + } \ + NRPRG(in_wrapper) = true; \ \ nr_segment_t* auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \ - if (!auto_segment || auto_segment->execute_data != execute_data) { \ + if (!auto_segment || auto_segment->execute_data != execute_data || \ + auto_segment == NRPRG(txn)->segment_root) { \ nr_php_observer_fcall_begin(execute_data); \ auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \ is_begin = true; \ } else { \ func_return_value_ptr = nr_php_get_return_value_ptr(); \ func_return_value = func_return_value_ptr ? *func_return_value_ptr : NULL;\ - nr_php_observer_fcall_end(execute_data, \ + nr_php_observer_fcall_end_keep_segment(execute_data, \ func_return_value_ptr ? *func_return_value_ptr : NULL); \ } #endif @@ -317,7 +322,10 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); } \ if (is_begin) { \ nr_php_observer_fcall_begin_late(execute_data, txn_start_time);\ - } \ + } else { \ + nr_php_observer_fcall_end_late(execute_data, false, txn_start_time); \ + } \ + NRPRG(in_wrapper) = false; \ if (zcaught) { \ zend_bailout(); \ } \ From 695ed36eda7ff7c1f786909c7460f62a7358a163 Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Thu, 9 May 2024 07:56:35 -0600 Subject: [PATCH 40/44] fix guzzle --- agent/lib_guzzle4.c | 13 +++++++++++++ agent/lib_guzzle4.h | 4 ++++ agent/lib_guzzle6.c | 12 ++++++++++++ agent/lib_guzzle6.h | 4 ++++ agent/php_wrapper.h | 7 ++----- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/agent/lib_guzzle4.c b/agent/lib_guzzle4.c index f3dfc94e9..0525ad85c 100644 --- a/agent/lib_guzzle4.c +++ b/agent/lib_guzzle4.c @@ -436,22 +436,33 @@ const zend_function_entry nr_guzzle4_subscriber_functions[] * Purpose : Registers an event subscriber for a newly instantiated * GuzzleHttp\Client object. */ + +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +void nr_guzzle4_client_construct(NR_EXECUTE_PROTO) { +#else NR_PHP_WRAPPER_START(nr_guzzle4_client_construct) { +#endif zval* emitter = NULL; zval* retval = NULL; zval* subscriber = NULL; zval* this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO (void)wraprec; +#endif 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)) { +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO NR_PHP_WRAPPER_CALL; +#endif goto end; } +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO NR_PHP_WRAPPER_CALL; +#endif /* * We can't have newrelic\Guzzle4\Subscriber implement @@ -503,7 +514,9 @@ NR_PHP_WRAPPER_START(nr_guzzle4_client_construct) { nr_php_zval_free(&emitter); nr_php_zval_free(&subscriber); } +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO NR_PHP_WRAPPER_END +#endif void nr_guzzle4_enable(TSRMLS_D) { if (0 == NRINI(guzzle_enabled)) { diff --git a/agent/lib_guzzle4.h b/agent/lib_guzzle4.h index b1f58de99..c9eef3d4c 100644 --- a/agent/lib_guzzle4.h +++ b/agent/lib_guzzle4.h @@ -26,6 +26,10 @@ extern void nr_guzzle4_rshutdown(TSRMLS_D); /* * Purpose : Client::__construct() wrapper for Guzzle 4. */ +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO extern NR_PHP_WRAPPER_PROTOTYPE(nr_guzzle4_client_construct); +#else +extern void nr_guzzle4_client_construct(NR_EXECUTE_PROTO); +#endif #endif /* LIB_GUZZLE4_HDR */ diff --git a/agent/lib_guzzle6.c b/agent/lib_guzzle6.c index a106eac71..ba33cab82 100644 --- a/agent/lib_guzzle6.c +++ b/agent/lib_guzzle6.c @@ -343,7 +343,11 @@ const zend_function_entry nr_guzzle6_requesthandler_functions[] /* }}} */ +#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +void nr_guzzle6_client_construct(NR_EXECUTE_PROTO) { +#else NR_PHP_WRAPPER_START(nr_guzzle6_client_construct) { +#endif zval* config; zend_class_entry* guzzle_client_ce; zval* handler_stack; @@ -364,16 +368,22 @@ NR_PHP_WRAPPER_START(nr_guzzle6_client_construct) { version); nr_free(version); +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO (void)wraprec; +#endif NR_UNUSED_SPECIALFN; /* This is how we distinguish Guzzle 4/5. */ if (nr_guzzle_does_zval_implement_has_emitter(this_var TSRMLS_CC)) { +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO NR_PHP_WRAPPER_CALL; +#endif goto end; } +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO NR_PHP_WRAPPER_CALL; +#endif /* * Get our middleware callable (which is just a string), and make sure it's @@ -420,7 +430,9 @@ NR_PHP_WRAPPER_START(nr_guzzle6_client_construct) { nr_php_zval_free(&middleware); nr_php_scope_release(&this_var); } +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO NR_PHP_WRAPPER_END +#endif void nr_guzzle6_enable(TSRMLS_D) { int retval; diff --git a/agent/lib_guzzle6.h b/agent/lib_guzzle6.h index 67bff7ecf..e66c97915 100644 --- a/agent/lib_guzzle6.h +++ b/agent/lib_guzzle6.h @@ -20,6 +20,10 @@ extern void nr_guzzle6_minit(TSRMLS_D); /* * Purpose : Client::__construct() wrapper for Guzzle 6. */ +#if ZEND_MODULE_API_NO < ZEND_8_2_X_API_NO extern NR_PHP_WRAPPER_PROTOTYPE(nr_guzzle6_client_construct); +#else +extern void nr_guzzle6_client_construct(NR_EXECUTE_PROTO); +#endif #endif /* LIB_GUZZLE4_HDR */ diff --git a/agent/php_wrapper.h b/agent/php_wrapper.h index 7c8aeb75d..20f9d0335 100644 --- a/agent/php_wrapper.h +++ b/agent/php_wrapper.h @@ -277,7 +277,7 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); const nrtxn_t* txn = NRPRG(txn); \ const nrtime_t txn_start_time = nr_txn_start_time(txn); \ if (NRPRG(in_wrapper)) { \ - printf("AAHHHHHHHHHHH\n"); \ + printf("AAHHHHHHHHHHH %s\n", #name); \ } \ NRPRG(in_wrapper) = true; \ \ @@ -384,10 +384,7 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); } #else #define NR_PHP_WRAPPER_DELEGATE(name) \ - if (!was_executed) { \ - ((name)(execute_data)); \ - was_executed = 1; \ - } + ((name)(execute_data, func_return_value)); #endif static inline bool is_instrumentation_set_and_not_equal( From 9c9d966ffd0125670b862e37b2fcdf1f7a4b3b64 Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Fri, 10 May 2024 10:54:01 -0600 Subject: [PATCH 41/44] fix return value stuff --- agent/fw_wordpress.c | 2 -- agent/php_execute.c | 10 ++++++++-- agent/php_wrapper.h | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/agent/fw_wordpress.c b/agent/fw_wordpress.c index 5aa99114b..07d306c32 100644 --- a/agent/fw_wordpress.c +++ b/agent/fw_wordpress.c @@ -346,7 +346,6 @@ NR_PHP_WRAPPER(nr_wordpress_wrap_hook_core) { NR_PHP_WRAPPER_LEAVE; } - NR_PHP_WRAPPER_CALL; if (NRPRG(wordpress_core)) { nr_wordpress_create_metric(auto_segment, NR_WORDPRESS_HOOK_PREFIX, tag); } @@ -374,7 +373,6 @@ NR_PHP_WRAPPER(nr_wordpress_wrap_hook_plugin) { plugin = wraprec->wordpress_plugin_theme; //plugin = nr_wordpress_plugin_from_function(execute_data->func); - NR_PHP_WRAPPER_CALL; if (NULL != plugin) { nr_wordpress_create_metric(auto_segment, NR_WORDPRESS_HOOK_PREFIX, tag); nr_wordpress_create_metric(auto_segment, NR_WORDPRESS_PLUGIN_PREFIX, diff --git a/agent/php_execute.c b/agent/php_execute.c index 90a19a400..f7fc17db0 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -2134,7 +2134,7 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo "Uncaught exception ", &NRPRG(exception_filters) TSRMLS_CC); } else if (NULL == nr_php_get_return_value(NR_EXECUTE_ORIG_ARGS)) { #else - if (NULL == nr_php_get_return_value(NR_EXECUTE_ORIG_ARGS)) { + if (NULL == func_return_value) { #endif /* * Having no return value (and not being an exception handler) indicates @@ -2146,6 +2146,9 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo nr_status_t status = nr_php_error_record_exception_segment( NRPRG(txn), &exception, &NRPRG(exception_filters)); + if (execute_data->func && execute_data->func->common.function_name) { + nrl_verbosedebug(NRL_AGENT, "END %s", ZSTR_VAL(execute_data->func->common.function_name)); + } if (NR_FAILURE == status) { nrl_verbosedebug(NRL_AGENT, "%s: unable to record exception on segment", @@ -2230,6 +2233,9 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) { //if (execute_data->func && execute_data->func->common.function_name) { // printf("BEGIN %s\n", ZSTR_VAL(execute_data->func->common.function_name)); //} + if (execute_data->func && execute_data->func->common.function_name) { + nrl_verbosedebug(NRL_AGENT, "BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name)); + } if (nrunlikely(NULL == execute_data)) { return; } @@ -2272,7 +2278,7 @@ void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) { */ zval* func_return_value = NULL; //if (execute_data->func && execute_data->func->common.function_name) { - // printf("BEGIN %s\n", ZSTR_VAL(execute_data->func->common.function_name)); + // nrl_verbosedebug(NRL_AGENT, "BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name)); //} if (nrunlikely(NULL == execute_data)) { return; diff --git a/agent/php_wrapper.h b/agent/php_wrapper.h index 20f9d0335..96ca7d07f 100644 --- a/agent/php_wrapper.h +++ b/agent/php_wrapper.h @@ -273,7 +273,6 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); bool is_begin = false; \ nruserfn_t* wraprec = NULL; \ zval* func_return_value = NULL; \ - zval** func_return_value_ptr = NULL; \ const nrtxn_t* txn = NRPRG(txn); \ const nrtime_t txn_start_time = nr_txn_start_time(txn); \ if (NRPRG(in_wrapper)) { \ @@ -288,10 +287,11 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \ is_begin = true; \ } else { \ - func_return_value_ptr = nr_php_get_return_value_ptr(); \ - func_return_value = func_return_value_ptr ? *func_return_value_ptr : NULL;\ + va_list ptr; \ + va_start(ptr, execute_data); \ + func_return_value = va_arg(ptr, zval*); \ nr_php_observer_fcall_end_keep_segment(execute_data, \ - func_return_value_ptr ? *func_return_value_ptr : NULL); \ + func_return_value); \ } #endif From 05935f25410d1428955c6dd1e4ec3dc2dd8f42b0 Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Tue, 14 May 2024 14:30:21 -0600 Subject: [PATCH 42/44] fix wrapper tracking --- agent/php_execute.c | 8 +------- agent/php_newrelic.h | 5 ----- agent/php_rinit.c | 5 +---- agent/php_wrapper.c | 3 +++ agent/php_wrapper.h | 22 ++++++++-------------- 5 files changed, 13 insertions(+), 30 deletions(-) diff --git a/agent/php_execute.c b/agent/php_execute.c index f7fc17db0..231dd6db2 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -2146,9 +2146,6 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO, bool create_metric, boo nr_status_t status = nr_php_error_record_exception_segment( NRPRG(txn), &exception, &NRPRG(exception_filters)); - if (execute_data->func && execute_data->func->common.function_name) { - nrl_verbosedebug(NRL_AGENT, "END %s", ZSTR_VAL(execute_data->func->common.function_name)); - } if (NR_FAILURE == status) { nrl_verbosedebug(NRL_AGENT, "%s: unable to record exception on segment", @@ -2233,9 +2230,6 @@ void nr_php_observer_fcall_begin(zend_execute_data* execute_data) { //if (execute_data->func && execute_data->func->common.function_name) { // printf("BEGIN %s\n", ZSTR_VAL(execute_data->func->common.function_name)); //} - if (execute_data->func && execute_data->func->common.function_name) { - nrl_verbosedebug(NRL_AGENT, "BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name)); - } if (nrunlikely(NULL == execute_data)) { return; } @@ -2278,7 +2272,7 @@ void nr_php_observer_fcall_begin_instrumented(zend_execute_data* execute_data) { */ zval* func_return_value = NULL; //if (execute_data->func && execute_data->func->common.function_name) { - // nrl_verbosedebug(NRL_AGENT, "BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name)); + // printf("BEGIN %s", ZSTR_VAL(execute_data->func->common.function_name)); //} if (nrunlikely(NULL == execute_data)) { return; diff --git a/agent/php_newrelic.h b/agent/php_newrelic.h index 8ec589937..7b44887bc 100644 --- a/agent/php_newrelic.h +++ b/agent/php_newrelic.h @@ -450,11 +450,6 @@ int symfony1_in_dispatch; /* Whether we are currently within a int symfony1_in_error404; /* Whether we are currently within a sfError404Exception::printStackTrace() frame */ -#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO \ - && !defined OVERWRITE_ZEND_EXECUTE_DATA -bool in_wrapper; -#endif - #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA bool check_cufa; diff --git a/agent/php_rinit.c b/agent/php_rinit.c index 5d8634292..922e4a884 100644 --- a/agent/php_rinit.c +++ b/agent/php_rinit.c @@ -124,12 +124,9 @@ PHP_RINIT_FUNCTION(newrelic) { nr_stack_init(&NRPRG(drupal_invoke_all_hooks), NR_STACK_DEFAULT_CAPACITY); nr_stack_init(&NRPRG(drupal_invoke_all_states), NR_STACK_DEFAULT_CAPACITY); NRPRG(predis_ctxs).dtor = str_stack_dtor; + NRPRG(wordpress_tags).dtor = str_stack_dtor; NRPRG(drupal_invoke_all_hooks).dtor = zval_stack_dtor; #endif -#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO \ - && !defined OVERWRITE_ZEND_EXECUTE_DATA - NRPRG(in_wrapper) = false; -#endif NRPRG(mysql_last_conn) = NULL; NRPRG(pgsql_last_conn) = NULL; diff --git a/agent/php_wrapper.c b/agent/php_wrapper.c index 9a39b42d4..398c1a59e 100644 --- a/agent/php_wrapper.c +++ b/agent/php_wrapper.c @@ -90,6 +90,9 @@ nruserfn_t* nr_php_wrap_callable_before_after( // begin_handler will be NULL if the observer hasn't been installed yet. // *begin_Handler will be NULL if the function has not yet been called. if (begin_handler && *begin_handler) { + name = nr_php_function_debug_name(callable); + php_printf("AHHHHHHH %s\n", name); + nr_free(name); // It is okay to attempt to remove a handler that doesn't exist // TODO this could remove nr_php_observer_fcall_begin/end and then re-add it :) if (zend_observer_remove_begin_handler(callable, NRINI(tt_detail) ? diff --git a/agent/php_wrapper.h b/agent/php_wrapper.h index 96ca7d07f..b1ec71553 100644 --- a/agent/php_wrapper.h +++ b/agent/php_wrapper.h @@ -269,27 +269,22 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); #define NR_PHP_WRAPPER_START(name) \ NR_PHP_WRAPPER_PROTOTYPE(name) { \ int was_executed = 0; \ + bool in_begin = true;\ int zcaught = 0; \ - bool is_begin = false; \ nruserfn_t* wraprec = NULL; \ zval* func_return_value = NULL; \ const nrtxn_t* txn = NRPRG(txn); \ const nrtime_t txn_start_time = nr_txn_start_time(txn); \ - if (NRPRG(in_wrapper)) { \ - printf("AAHHHHHHHHHHH %s\n", #name); \ - } \ - NRPRG(in_wrapper) = true; \ \ nr_segment_t* auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \ - if (!auto_segment || auto_segment->execute_data != execute_data || \ - auto_segment == NRPRG(txn)->segment_root) { \ + if (!auto_segment || auto_segment->execute_data != execute_data) { \ nr_php_observer_fcall_begin(execute_data); \ - auto_segment = nr_txn_get_current_segment(NRPRG(txn), NULL); \ - is_begin = true; \ } else { \ - va_list ptr; \ - va_start(ptr, execute_data); \ - func_return_value = va_arg(ptr, zval*); \ + va_list args; \ + va_start(args, execute_data); \ + func_return_value = va_arg(args, zval*); \ + va_end(args); \ + in_begin = false; \ nr_php_observer_fcall_end_keep_segment(execute_data, \ func_return_value); \ } @@ -320,12 +315,11 @@ extern zval** nr_php_get_return_value_ptr(TSRMLS_D); if (!was_executed) { \ NR_PHP_WRAPPER_CALL \ } \ - if (is_begin) { \ + if (in_begin) { \ nr_php_observer_fcall_begin_late(execute_data, txn_start_time);\ } else { \ nr_php_observer_fcall_end_late(execute_data, false, txn_start_time); \ } \ - NRPRG(in_wrapper) = false; \ if (zcaught) { \ zend_bailout(); \ } \ From 215fcc4a6a94b4ee48940a792d46fe8cc6e2808c Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Wed, 15 May 2024 09:03:53 -0600 Subject: [PATCH 43/44] try not using zend lookup --- agent/php_user_instrument.c | 2 +- agent/php_wrapper.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/php_user_instrument.c b/agent/php_user_instrument.c index 62b9fb942..b607e24eb 100644 --- a/agent/php_user_instrument.c +++ b/agent/php_user_instrument.c @@ -493,7 +493,7 @@ nruserfn_t* nr_php_add_custom_tracer_named(const char* namestr, * non-transients to be freed when the linked list is disposed of which is at * module shutdown */ nr_php_add_custom_tracer_common(wraprec); -#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +#if ZEND_MODULE_API_NO >= ZEND_8_3_X_API_NO if (orig_func) { // Before messing with our handlers, we must ensure that the observer fields of the function are initialized begin_handler = (zend_observer_fcall_begin_handler *)&ZEND_OP_ARRAY_EXTENSION((&(orig_func)->common), zend_observer_fcall_op_array_extension); diff --git a/agent/php_wrapper.c b/agent/php_wrapper.c index 398c1a59e..bbdb3356e 100644 --- a/agent/php_wrapper.c +++ b/agent/php_wrapper.c @@ -83,7 +83,7 @@ nruserfn_t* nr_php_wrap_callable_before_after( if (nrl_should_print(NRL_VERBOSEDEBUG, NRL_INSTRUMENT) && NULL != name) { nr_free(name); } -#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +#if ZEND_MODULE_API_NO >= ZEND_8_3_X_API_NO if (callable) { // Before messing with our handlers, we must ensure that the observer fields of the function are initialized begin_handler = (zend_observer_fcall_begin_handler *)&ZEND_OP_ARRAY_EXTENSION((&(callable)->common), zend_observer_fcall_op_array_extension); @@ -165,7 +165,7 @@ nruserfn_t* nr_php_wrap_callable(zend_function* callable, __func__); } else { wraprec->special_instrumentation = callback; -#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +#if ZEND_MODULE_API_NO >= ZEND_8_3_X_API_NO if (callable) { // Before messing with our handlers, we must ensure that the observer fields of the function are initialized begin_handler = (zend_observer_fcall_begin_handler *)&ZEND_OP_ARRAY_EXTENSION((&(callable)->common), zend_observer_fcall_op_array_extension); From 8eaf488a87d351a05e006d7b05ba1911a62c3a01 Mon Sep 17 00:00:00 2001 From: Zach Neumann Date: Wed, 15 May 2024 09:07:48 -0600 Subject: [PATCH 44/44] fix --- agent/php_user_instrument.c | 4 ++-- agent/php_wrapper.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/agent/php_user_instrument.c b/agent/php_user_instrument.c index b607e24eb..3e91d13f2 100644 --- a/agent/php_user_instrument.c +++ b/agent/php_user_instrument.c @@ -450,7 +450,7 @@ nruserfn_t* nr_php_add_custom_tracer_named(const char* namestr, size_t namestrlen) { nruserfn_t* wraprec; nruserfn_t* p; -#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +#if ZEND_MODULE_API_NO >= ZEND_8_3_X_API_NO zend_function* orig_func; zend_observer_fcall_begin_handler *begin_handler; #endif @@ -483,7 +483,7 @@ nruserfn_t* nr_php_add_custom_tracer_named(const char* namestr, NRP_PHP(wraprec->classname), (0 == wraprec->classname) ? "" : "::", NRP_PHP(wraprec->funcname)); -#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +#if ZEND_MODULE_API_NO >= ZEND_8_3_X_API_NO orig_func = nr_php_wrap_user_function_internal(wraprec TSRMLS_CC); #else nr_php_wrap_user_function_internal(wraprec TSRMLS_CC); diff --git a/agent/php_wrapper.c b/agent/php_wrapper.c index bbdb3356e..f9867d0c8 100644 --- a/agent/php_wrapper.c +++ b/agent/php_wrapper.c @@ -64,7 +64,7 @@ nruserfn_t* nr_php_wrap_callable_before_after( nrspecialfn_t before_callback, nrspecialfn_t after_callback) { char* name = NULL; -#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +#if ZEND_MODULE_API_NO >= ZEND_8_3_X_API_NO zend_observer_fcall_begin_handler *begin_handler; #endif @@ -152,7 +152,7 @@ nruserfn_t* nr_php_wrap_callable(zend_function* callable, nrspecialfn_t callback TSRMLS_DC) { /* creates a transient wraprec */ nruserfn_t* wraprec = nr_php_add_custom_tracer_callable(callable TSRMLS_CC); -#if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO +#if ZEND_MODULE_API_NO >= ZEND_8_3_X_API_NO zend_observer_fcall_begin_handler *begin_handler; #endif