Skip to content

Commit

Permalink
fix(tests): Enhances error trace inspection for linking
Browse files Browse the repository at this point in the history
Adds test to check the "guid" intrinsics attribute in addition to the
"CatsGuid" field.
  • Loading branch information
mfulb committed Mar 5, 2024
1 parent 711a5e8 commit 7eabda6
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
23 changes: 22 additions & 1 deletion tests/integration/errors/test_error_linking_dt_off_cat_off.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
]
*/


/*EXPECT
ok - Error trace payload length
ok - Error trace CatsGUID is txn guid
ok - Error trace contains intrinsics
ok - Error trace intrinsics contains guid
ok - Error trace intrisics guid is txn guid
*/

require_once(realpath (dirname ( __FILE__ )) . '/../../include/tap.php');

function throw_it() {
Expand All @@ -56,5 +65,17 @@ function throw_it() {
/* capture error trace json and verify transaction GUID */
$json = newrelic_get_error_json();
$payload = json_decode($json, true);

$guid = newrelic_get_transaction_guid();
tap_equal($guid, $payload[5], "Error trace includes txn guid");

tap_equal(6, count($payload), "Error trace payload length");

$catsguid = $payload[5];
tap_equal($guid, $catsguid, "Error trace CatsGUID is txn guid");

tap_assert(array_key_exists("intrinsics", $payload[4]), "Error trace contains intrinsics");

$intrinsics = $payload[4]["intrinsics"];

tap_assert(array_key_exists("guid", $intrinsics), "Error trace intrinsics contains guid");
tap_equal($guid, $intrinsics["guid"], "Error trace intrisics guid is txn guid");
22 changes: 21 additions & 1 deletion tests/integration/errors/test_error_linking_dt_off_cat_on.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
]
*/

/*EXPECT
ok - Error trace payload length
ok - Error trace CatsGUID is txn guid
ok - Error trace contains intrinsics
ok - Error trace intrinsics contains guid
ok - Error trace intrisics guid is txn guid
*/

require_once(realpath (dirname ( __FILE__ )) . '/../../include/tap.php');

function throw_it() {
Expand All @@ -56,5 +64,17 @@ function throw_it() {
/* capture error trace json and verify transaction GUID */
$json = newrelic_get_error_json();
$payload = json_decode($json, true);

$guid = newrelic_get_transaction_guid();
tap_equal($guid, $payload[5], "Error trace includes txn guid");

tap_equal(6, count($payload), "Error trace payload length");

$catsguid = $payload[5];
tap_equal($guid, $catsguid, "Error trace CatsGUID is txn guid");

tap_assert(array_key_exists("intrinsics", $payload[4]), "Error trace contains intrinsics");

$intrinsics = $payload[4]["intrinsics"];

tap_assert(array_key_exists("guid", $intrinsics), "Error trace intrinsics contains guid");
tap_equal($guid, $intrinsics["guid"], "Error trace intrisics guid is txn guid");
25 changes: 24 additions & 1 deletion tests/integration/errors/test_error_linking_dt_on_cat_off.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
]
*/

/*EXPECT
ok - Error trace payload length
ok - Error trace CatsGUID is txn guid
ok - Error trace contains intrinsics
ok - Error trace intrinsics contains guid
ok - Error trace intrisics guid is txn guid
*/

require_once(realpath (dirname ( __FILE__ )) . '/../../include/tap.php');

function throw_it() {
Expand All @@ -56,5 +64,20 @@ function throw_it() {
/* capture error trace json and verify transaction GUID */
$json = newrelic_get_error_json();
$payload = json_decode($json, true);

$guid = newrelic_get_transaction_guid();
tap_equal($guid, $payload[5], "Error trace includes txn guid");

tap_equal(6, count($payload), "Error trace payload length");

$catsguid = $payload[5];
tap_equal($guid, $catsguid, "Error trace CatsGUID is txn guid");

tap_assert(array_key_exists("intrinsics", $payload[4]), "Error trace contains intrinsics");

$intrinsics = $payload[4]["intrinsics"];

tap_assert(array_key_exists("guid", $intrinsics), "Error trace intrinsics contains guid");
tap_equal($guid, $intrinsics["guid"], "Error trace intrisics guid is txn guid");



0 comments on commit 7eabda6

Please sign in to comment.