Skip to content

Commit

Permalink
Update Statsbeat Network Metric Names (#1276)
Browse files Browse the repository at this point in the history
* Update statsbeat values to be consistent with the exporter.

* Update statsbeat tests.
  • Loading branch information
JacksonWeber authored Feb 15, 2024
1 parent 9603259 commit ab2b4a1
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 78 deletions.
12 changes: 6 additions & 6 deletions Declarations/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
28 changes: 14 additions & 14 deletions Tests/AutoCollection/Statsbeat.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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((<any>(metric.properties))["attach"], "IntegratedAuto");
Expand All @@ -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();
Expand Down Expand Up @@ -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((<any>(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((<any>(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((<any>(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((<any>(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); });
Expand Down Expand Up @@ -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((<any>(metric.properties))["endpoint"], 0);
assert.equal((<any>(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((<any>(metric.properties))["endpoint"], 1);
assert.equal((<any>(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((<any>(metric.properties))["endpoint"], 0);
Expand Down
158 changes: 100 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ab2b4a1

Please sign in to comment.