From 8a73dde5bab68356599dfd14ea93b5654665de84 Mon Sep 17 00:00:00 2001 From: Amber Sistla Date: Thu, 9 Jan 2025 11:31:23 -0700 Subject: [PATCH] fix(axiom): externalCallCount should be added to the txn not just the error (#1006) --- axiom/nr_txn.c | 2 ++ axiom/tests/test_cmd_txndata.c | 1 + axiom/tests/test_txn.c | 5 +++ .../external/curl_exec/test_dt_simple.php | 30 +++++++++++++++++ .../test_spans_are_created_correctly.php | 29 ++++++++++++++++ ...t_uncaught_bad_response_exception_sync.php | 33 +++++++++++++++++++ .../synthetics/test_happy_path_with_dt.php | 1 + 7 files changed, 101 insertions(+) diff --git a/axiom/nr_txn.c b/axiom/nr_txn.c index 774c44671..4e5c4c41e 100644 --- a/axiom/nr_txn.c +++ b/axiom/nr_txn.c @@ -2582,6 +2582,8 @@ nrobj_t* nr_txn_event_intrinsics(const nrtxn_t* txn) { params, txn->unscoped_metrics, "WebFrontend/QueueTime", "queueDuration"); nr_txn_add_metric_total_as_attribute(params, txn->unscoped_metrics, "External/all", "externalDuration"); + nr_txn_add_metric_count_as_attribute(params, txn->unscoped_metrics, + "External/all", "externalCallCount"); nr_txn_add_metric_total_as_attribute(params, txn->unscoped_metrics, "Datastore/all", "databaseDuration"); nr_txn_add_metric_count_as_attribute(params, txn->unscoped_metrics, diff --git a/axiom/tests/test_cmd_txndata.c b/axiom/tests/test_cmd_txndata.c index fc9272e1c..1107d9a79 100644 --- a/axiom/tests/test_cmd_txndata.c +++ b/axiom/tests/test_cmd_txndata.c @@ -1094,6 +1094,7 @@ static void test_encode_txn_event(void) { "\"duration\":0.98700,\"totalTime\":0.98700,\"nr.apdexPerfZone\":" "\"F\"," "\"queueDuration\":3.00000,\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":2.00000," "\"databaseCallCount\":2," "\"error\":false}," diff --git a/axiom/tests/test_txn.c b/axiom/tests/test_txn.c index 9230a416a..279bbbbee 100644 --- a/axiom/tests/test_txn.c +++ b/axiom/tests/test_txn.c @@ -4056,6 +4056,7 @@ static void test_create_event(void) { "\"nr.apdexPerfZone\":\"F\"," "\"queueDuration\":3.00000," "\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":1.00000," "\"databaseCallCount\":1," "\"error\":false" @@ -4078,6 +4079,7 @@ static void test_create_event(void) { "\"totalTime\":0.98700," "\"queueDuration\":3.00000," "\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":1.00000," "\"databaseCallCount\":1," "\"error\":false" @@ -4103,6 +4105,7 @@ static void test_create_event(void) { "\"nr.apdexPerfZone\":\"F\"," "\"queueDuration\":3.00000," "\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":1.00000," "\"databaseCallCount\":1," "\"error\":false" @@ -4126,6 +4129,7 @@ static void test_create_event(void) { "\"nr.apdexPerfZone\":\"F\"," "\"queueDuration\":3.00000," "\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":1.00000," "\"databaseCallCount\":1," "\"error\":false" @@ -4148,6 +4152,7 @@ static void test_create_event(void) { "\"nr.apdexPerfZone\":\"F\"," "\"queueDuration\":3.00000," "\"externalDuration\":2.00000," + "\"externalCallCount\":1," "\"databaseDuration\":1.00000," "\"databaseCallCount\":1," "\"error\":false" diff --git a/tests/integration/external/curl_exec/test_dt_simple.php b/tests/integration/external/curl_exec/test_dt_simple.php index 5574bcf38..b7009267a 100644 --- a/tests/integration/external/curl_exec/test_dt_simple.php +++ b/tests/integration/external/curl_exec/test_dt_simple.php @@ -28,6 +28,36 @@ /*EXPECT_RESPONSE_HEADERS */ +/*EXPECT_ANALYTICS_EVENTS +[ + "?? agent run id", + { + "reservoir_size": 50, + "events_seen": 1 + }, + [ + [ + { + "type": "Transaction", + "name": "OtherTransaction\/php__FILE__", + "timestamp": "??", + "duration": "??", + "totalTime": "??", + "externalDuration": "??", + "externalCallCount": 1, + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??", + "error": false + }, + {}, + {} + ] + ] +] +*/ + /*EXPECT_TRACED_ERRORS null */ diff --git a/tests/integration/external/guzzle7/test_spans_are_created_correctly.php b/tests/integration/external/guzzle7/test_spans_are_created_correctly.php index 87388da64..4ec83c617 100644 --- a/tests/integration/external/guzzle7/test_spans_are_created_correctly.php +++ b/tests/integration/external/guzzle7/test_spans_are_created_correctly.php @@ -19,6 +19,35 @@ newrelic.transaction_tracer.detail = 0 */ +/*EXPECT_ANALYTICS_EVENTS +[ + "?? agent run id", + { + "reservoir_size": 50, + "events_seen": 1 + }, + [ + [ + { + "type": "Transaction", + "name": "OtherTransaction\/php__FILE__", + "timestamp": "??", + "duration": "??", + "totalTime": "??", + "externalDuration": "??", + "externalCallCount": 1, + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??", + "error": false + }, + {}, + {} + ] + ] +] +*/ /*EXPECT_SPAN_EVENTS_LIKE [ 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 index 88e2acdaf..98172f8ef 100644 --- a/tests/integration/external/guzzle7/test_uncaught_bad_response_exception_sync.php +++ b/tests/integration/external/guzzle7/test_uncaught_bad_response_exception_sync.php @@ -81,6 +81,39 @@ ] */ +/*EXPECT_ANALYTICS_EVENTS +[ + "?? agent run id", + { + "reservoir_size": 50, + "events_seen": 1 + }, + [ + [ + { + "type": "Transaction", + "name": "OtherTransaction\/php__FILE__", + "timestamp": "??", + "duration": "??", + "totalTime": "??", + "externalDuration": "??", + "externalCallCount": 1, + "guid": "??", + "sampled": true, + "priority": "??", + "traceId": "??", + "error": true + }, + {}, + { + "errorType": "GuzzleHttp\\Exception\\BadResponseException", + "errorMessage": "Uncaught exception 'GuzzleHttp\\Exception\\BadResponseException' with message 'ClientException' in __FILE__:??" + } + ] + ] +] +*/ + /*EXPECT_TRACED_ERRORS [ "?? agent run id", diff --git a/tests/integration/synthetics/test_happy_path_with_dt.php b/tests/integration/synthetics/test_happy_path_with_dt.php index 855a35e2a..bd415e684 100644 --- a/tests/integration/synthetics/test_happy_path_with_dt.php +++ b/tests/integration/synthetics/test_happy_path_with_dt.php @@ -62,6 +62,7 @@ "nr.syntheticsJobId": "jjjjjjj-jjjj-1234-jjjj-jjjjjjjjjjjj", "nr.syntheticsMonitorId": "mmmmmmm-mmmm-1234-mmmm-mmmmmmmmmmmm", "externalDuration": "??", + "externalCallCount": 1, "guid": "??", "sampled": true, "priority": "??",