Skip to content

Commit

Permalink
Address Negative Average Duration (microsoft#1039)
Browse files Browse the repository at this point in the history
* Bring short host value up to spec.

* Fix EU regions to comply with spec and fix reporting negative statsbeat.
  • Loading branch information
JacksonWeber authored Dec 1, 2022
1 parent 358fbce commit 39213a3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions AutoCollection/Statsbeat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 39213a3

Please sign in to comment.