From ab2b4a1bf45adc6fa5cc61e0ab1b5d760f635d67 Mon Sep 17 00:00:00 2001 From: Jackson Weber <47067795+JacksonWeber@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:26:02 -0800 Subject: [PATCH] Update Statsbeat Network Metric Names (#1276) * Update statsbeat values to be consistent with the exporter. * Update statsbeat tests. --- Declarations/Constants.ts | 12 +- Tests/AutoCollection/Statsbeat.tests.ts | 28 ++--- package-lock.json | 158 +++++++++++++++--------- 3 files changed, 120 insertions(+), 78 deletions(-) diff --git a/Declarations/Constants.ts b/Declarations/Constants.ts index 7e5e1f4b7..fe256690c 100644 --- a/Declarations/Constants.ts +++ b/Declarations/Constants.ts @@ -147,12 +147,12 @@ export const StatsbeatAttach = { } export const StatsbeatCounter = { - REQUEST_SUCCESS: "Request Success Count", - REQUEST_FAILURE: "Request Failure Count", - REQUEST_DURATION: "Request Duration", - RETRY_COUNT: "Retry Count", - THROTTLE_COUNT: "Throttle Count", - EXCEPTION_COUNT: "Exception Count", + REQUEST_SUCCESS: "Request_Success_Count", + REQUEST_FAILURE: "Request_Failure_Count", + REQUEST_DURATION: "Request_Duration", + RETRY_COUNT: "Retry_Count", + THROTTLE_COUNT: "Throttle_Count", + EXCEPTION_COUNT: "Exception_Count", ATTACH: "Attach", FEATURE: "Feature" } diff --git a/Tests/AutoCollection/Statsbeat.tests.ts b/Tests/AutoCollection/Statsbeat.tests.ts index 75f337403..f8bc799b8 100644 --- a/Tests/AutoCollection/Statsbeat.tests.ts +++ b/Tests/AutoCollection/Statsbeat.tests.ts @@ -149,7 +149,7 @@ describe("AutoCollection/Statsbeat", () => { statsBeat.setCodelessAttach(); statsBeat.trackShortIntervalStatsbeats().then(() => { assert.ok(sendStub.called, "should call _sendStatsbeats"); - let metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Request Duration")[0]; + let metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Request_Duration")[0]; assert.ok(metric, "Statsbeat Request not found"); assert.equal(metric.value, 123); assert.equal(((metric.properties))["attach"], "IntegratedAuto"); @@ -174,7 +174,7 @@ describe("AutoCollection/Statsbeat", () => { statsBeat.trackShortIntervalStatsbeats().then((error) => { assert.ok(sendStub.called, "should call _sendStatsbeats"); assert.equal(statsBeat["_statbeatMetrics"].length, 3); - let metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Request Duration")[0]; + let metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Request_Duration")[0]; assert.ok(metric, "Request Duration metric not found"); assert.equal(metric.value, 750); done(); @@ -202,36 +202,36 @@ describe("AutoCollection/Statsbeat", () => { statsBeat.trackShortIntervalStatsbeats().then(() => { assert.ok(sendStub.called, "should call _sendStatsbeats"); assert.equal(statsBeat["_statbeatMetrics"].length, 11); - let metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Request Success Count")[0]; + let metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Request_Success_Count")[0]; assert.ok(metric, "Request Success Count metric not found"); assert.equal(metric.value, 4); - metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Request Failure Count")[0]; + metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Request_Failure_Count")[0]; assert.ok(metric, "Request Failure Count metric not found"); assert.equal(((metric.properties))["statusCode"], 500); assert.equal(metric.value, 2); - let metricCount = statsBeat["_statbeatMetrics"].filter(f => f.name === "Request Failure Count"); + let metricCount = statsBeat["_statbeatMetrics"].filter(f => f.name === "Request_Failure_Count"); assert.equal(metricCount.length, 3); - metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Retry Count")[0]; + metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Retry_Count")[0]; assert.ok(metric, "Retry Count metric not found"); assert.equal(((metric.properties))["statusCode"], 206); assert.equal(metric.value, 2); - metricCount = statsBeat["_statbeatMetrics"].filter(f => f.name === "Retry Count"); + metricCount = statsBeat["_statbeatMetrics"].filter(f => f.name === "Retry_Count"); assert.equal(metricCount.length, 2); - metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Throttle Count")[0]; + metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Throttle_Count")[0]; assert.ok(metric, "Throttle Count metric not found"); assert.equal(((metric.properties))["statusCode"], 402); assert.equal(metric.value, 1); - metricCount = statsBeat["_statbeatMetrics"].filter(f => f.name === "Throttle Count"); + metricCount = statsBeat["_statbeatMetrics"].filter(f => f.name === "Throttle_Count"); assert.equal(metricCount.length, 2); - metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Exception Count")[0]; + metric = statsBeat["_statbeatMetrics"].filter(f => f.name === "Exception_Count")[0]; assert.ok(metric, "Exception Count metric not found"); assert.equal(metric.value, 1); assert.equal(((metric.properties))["exceptionType"], "Statsbeat"); - metricCount = statsBeat["_statbeatMetrics"].filter(f => f.name === "Exception Count"); + metricCount = statsBeat["_statbeatMetrics"].filter(f => f.name === "Exception_Count"); assert.equal(metricCount.length, 2); done(); }).catch((error) => { done(error); }); @@ -337,17 +337,17 @@ describe("AutoCollection/Statsbeat", () => { statsBeat.countRequest(0, "breezeSecondEndpoint", 400, true, 200); statsBeat.trackShortIntervalStatsbeats().then(() => { assert.ok(sendStub.called, "should call _sendStatsbeats"); - let metric: any = statsBeat["_statbeatMetrics"].find(f => f.name === "Request Duration" + let metric: any = statsBeat["_statbeatMetrics"].find(f => f.name === "Request_Duration" && f.value === 100); assert.ok(metric, "breezeFirstEndpoint metric not found"); assert.equal(((metric.properties))["endpoint"], 0); assert.equal(((metric.properties))["host"], "breezeFirstEndpoint"); - metric = statsBeat["_statbeatMetrics"].find(f => f.name === "Request Duration" + metric = statsBeat["_statbeatMetrics"].find(f => f.name === "Request_Duration" && f.value === 200); assert.ok(metric, "quickpulseEndpoint metric not found"); assert.equal(((metric.properties))["endpoint"], 1); assert.equal(((metric.properties))["host"], "quickpulseEndpoint"); - metric = statsBeat["_statbeatMetrics"].find(f => f.name === "Request Duration" + metric = statsBeat["_statbeatMetrics"].find(f => f.name === "Request_Duration" && f.value === 400); assert.ok(metric, "breezeSecondEndpoint metric not found"); assert.equal(((metric.properties))["endpoint"], 0); diff --git a/package-lock.json b/package-lock.json index c3e99d6e3..6d36e3e0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -706,14 +706,18 @@ "dev": true }, "node_modules/call-bind": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", - "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.6.tgz", + "integrity": "sha512-Mj50FLHtlsoVfRfnHaZvyrooHcrlceNZdL/QBvJJVd9Ta55qCQK0gs4ss2oZDeV9zFCs6ewzYgVE5yfVmfFpVg==", "dev": true, "dependencies": { + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.1", - "set-function-length": "^1.1.1" + "get-intrinsic": "^1.2.3", + "set-function-length": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -949,14 +953,15 @@ "dev": true }, "node_modules/define-data-property": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", - "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.2.tgz", + "integrity": "sha512-SRtsSqsDbgpJBbW3pABMCOt6rQyeM8s8RiyeSN8jYG8sYmt/kGJejbydttUsnDs1tadr19tvhT4ShwMyoqAm4g==", "dev": true, "dependencies": { - "get-intrinsic": "^1.2.1", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.2", "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "has-property-descriptors": "^1.0.1" }, "engines": { "node": ">= 0.4" @@ -1036,10 +1041,19 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", "dev": true, "engines": { "node": ">=6" @@ -1290,9 +1304,9 @@ "dev": true }, "node_modules/fastq": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.0.tgz", - "integrity": "sha512-zGygtijUMT7jnk3h26kUms3BkSDp4IfIKjmnqI2tvx6nuBfiF1UqOxbnLfzdv+apBy+53oaImsKtMw/xYbW+1w==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -1481,35 +1495,38 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", - "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dev": true, "dependencies": { + "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimatch": "^5.0.1", + "once": "^1.3.0" }, "engines": { - "node": "*" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -1527,6 +1544,27 @@ "node": ">=10.13.0" } }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/globals": { "version": "13.24.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", @@ -1627,9 +1665,9 @@ "dev": true }, "node_modules/hasown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", - "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz", + "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==", "dependencies": { "function-bind": "^1.1.2" }, @@ -2135,9 +2173,9 @@ } }, "node_modules/mocha": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", - "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.3.0.tgz", + "integrity": "sha512-uF2XJs+7xSLsrmIvn37i/wnc91nw7XjOQB8ccyx5aEgdnohr7n+rEiZP23WkCYHjilR6+EboEnbq/ZQDz4LSbg==", "dev": true, "dependencies": { "ansi-colors": "4.1.1", @@ -2147,13 +2185,12 @@ "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.2.0", + "glob": "8.1.0", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.3.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", @@ -2168,10 +2205,6 @@ }, "engines": { "node": ">= 14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mochajs" } }, "node_modules/mocha/node_modules/brace-expansion": { @@ -2232,18 +2265,6 @@ "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==", "dev": true }, - "node_modules/nanoid": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", - "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", - "dev": true, - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -2618,6 +2639,26 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rimraf/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -2675,9 +2716,9 @@ "dev": true }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -2704,14 +2745,15 @@ "dev": true }, "node_modules/set-function-length": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", - "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", + "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==", "dev": true, "dependencies": { - "define-data-property": "^1.1.1", + "define-data-property": "^1.1.2", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.2", + "get-intrinsic": "^1.2.3", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.1" },