Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(agent): Add supportability metrics for packages that provide major version #868

Merged
merged 21 commits into from
Apr 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
879b332
feat(agent): create new function that sends up supportability metrics…
hahuja2 Mar 25, 2024
2a83042
feat(agent): add supportability metrics for packages that provide ver…
hahuja2 Mar 25, 2024
08dbf01
feat(agent): add if statement to check if major version is more than …
hahuja2 Mar 26, 2024
cfa5e7f
feat(agent): set major version to first digit only in else statement
hahuja2 Mar 27, 2024
9ff6234
feat(agent): improve how the major version is found
hahuja2 Mar 27, 2024
3d36800
chore(agent): add check to ensure major version is not null
hahuja2 Mar 27, 2024
2b4836a
chore(agent): set predis to specific version instead of latest
hahuja2 Mar 27, 2024
67eaae4
chore(agent): add new supportability metric to guzzle and predis tests
hahuja2 Mar 27, 2024
e32440d
chore(agent): add if statement to not run predis tests on PHP 7.0/7.1
hahuja2 Mar 28, 2024
5248b97
chore(agent): add supportability metrics for guzzle and monolog by ma…
hahuja2 Mar 29, 2024
1fb5879
chore(agent): add macro to remove duplication
hahuja2 Mar 29, 2024
e94e897
chore(agent): fix error
hahuja2 Mar 29, 2024
4b61257
chore(agent): simplify how we look for major version
hahuja2 Apr 8, 2024
c8f52a4
chore(agent): add unit tests for package detection supportability metric
hahuja2 Apr 9, 2024
4231922
chore(agent): increase size to account for null terminator
hahuja2 Apr 9, 2024
5eedee9
chore(agent): change where version is defined
hahuja2 Apr 9, 2024
15c0422
chore(agent): define version at the top
hahuja2 Apr 9, 2024
97c639e
chore(agent): add additional tests
hahuja2 Apr 10, 2024
647d424
chore(agent): add supportability metric even when VM is disabled
hahuja2 Apr 10, 2024
0fc0bde
chore(agent): update description
hahuja2 Apr 10, 2024
55c1e1e
chore(agent): define major version length
hahuja2 Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions agent/tests/test_fw_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ 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"
zsistla marked this conversation as resolved.
Show resolved Hide resolved
#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);
Expand All @@ -36,6 +43,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",
Expand All @@ -51,6 +70,42 @@ 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"));

nrm_table_destroy(&txn->unscoped_metrics);
}

Expand Down
Loading