From 39213a322ce18f162dd7bb85e87408510d639601 Mon Sep 17 00:00:00 2001 From: Jackson Weber <47067795+JacksonWeber@users.noreply.github.com> Date: Thu, 1 Dec 2022 09:23:27 -0800 Subject: [PATCH] Address Negative Average Duration (#1039) * Bring short host value up to spec. * Fix EU regions to comply with spec and fix reporting negative statsbeat. --- AutoCollection/Statsbeat.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/AutoCollection/Statsbeat.ts b/AutoCollection/Statsbeat.ts index 946e9751..f3c35d8d 100644 --- a/AutoCollection/Statsbeat.ts +++ b/AutoCollection/Statsbeat.ts @@ -250,10 +250,11 @@ class Statsbeat { private _trackRequestDuration(commonProperties: {}) { for (let i = 0; i < this._networkStatsbeatCollection.length; i++) { - var currentCounter = this._networkStatsbeatCollection[i]; + let currentCounter = this._networkStatsbeatCollection[i]; currentCounter.time = +new Date; - var intervalRequests = (currentCounter.totalRequestCount - currentCounter.lastRequestCount) || 0; - var averageRequestExecutionTime = ((currentCounter.intervalRequestExecutionTime - currentCounter.lastIntervalRequestExecutionTime) / intervalRequests) || 0; + let intervalRequests = (currentCounter.totalRequestCount - currentCounter.lastRequestCount) || 0; + let totalRequestExecutionTime = currentCounter.intervalRequestExecutionTime - currentCounter.lastIntervalRequestExecutionTime; + let averageRequestExecutionTime = totalRequestExecutionTime > 0 ? (totalRequestExecutionTime / intervalRequests) || 0 : 0; currentCounter.lastIntervalRequestExecutionTime = currentCounter.intervalRequestExecutionTime; // reset if (intervalRequests > 0) { // Add extra properties @@ -284,6 +285,7 @@ class Statsbeat { if (res != null && res.length > 1) { shortHost = res[1]; } + shortHost = shortHost.replace(".in.applicationinsights.azure.com", ""); } catch (error) { // Ignore error @@ -435,7 +437,9 @@ class Statsbeat { "norwaywest", "swedencentral", "switzerlandnorth", - "switzerlandwest" + "switzerlandwest", + "uksouth", + "ukwest" ]; for (let i = 0; i < euEndpoints.length; i++) { if (currentEndpoint.indexOf(euEndpoints[i]) > -1) {