From edfc00b9ff082dbbe4fb1f58d732abf286333d10 Mon Sep 17 00:00:00 2001 From: Juan Perata Date: Tue, 25 Sep 2018 17:17:22 -0500 Subject: [PATCH 1/3] Add bst version to stats --- bin/bst-speak.ts | 2 +- bin/bst-test.ts | 2 +- lib/client/bst-virtual-alexa.ts | 6 +++--- lib/server/node-manager.ts | 2 +- lib/statistics/bst-statistics.ts | 10 +++++----- package-lock.json | 12 ++++++------ test/statistics/bst-statistics-test.ts | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/bin/bst-speak.ts b/bin/bst-speak.ts index 2a92be94..c154217a 100644 --- a/bin/bst-speak.ts +++ b/bin/bst-speak.ts @@ -66,7 +66,7 @@ Global.initializeCLI().then( if (Global.config() && Global.config().secretKey && Global.config().secretKey()) { nodeId = Global.config().secretKey(); } - BstStatistics.instance().record(BstCommand.speak, undefined, nodeId); + BstStatistics.instance().record(BstCommand.speak, undefined, nodeId, Global.version()); console.log(VirtualDeviceClient.renderResult(virtualDeviceResponse)); }); diff --git a/bin/bst-test.ts b/bin/bst-test.ts index e5bfabef..618e8cd0 100644 --- a/bin/bst-test.ts +++ b/bin/bst-test.ts @@ -62,7 +62,7 @@ Global.initializeCLI(false).then(() => { if (Global.config() && Global.config().secretKey && Global.config().secretKey()) { nodeId = Global.config().secretKey(); } - BstStatistics.instance().record(BstCommand.test, undefined, nodeId); + BstStatistics.instance().record(BstCommand.test, undefined, nodeId, Global.version()); process.exitCode = success ? 0 : 1; }); }); diff --git a/lib/client/bst-virtual-alexa.ts b/lib/client/bst-virtual-alexa.ts index 12fa2e94..ef347f98 100644 --- a/lib/client/bst-virtual-alexa.ts +++ b/lib/client/bst-virtual-alexa.ts @@ -221,7 +221,7 @@ export class BSTVirtualAlexa { }).catch(error => { callback(error, null, request); }); - BstStatistics.instance().record(BstCommand.utter, undefined, this.nodeId); + BstStatistics.instance().record(BstCommand.utter, undefined, this.nodeId, Global.version()); return this; } @@ -244,7 +244,7 @@ export class BSTVirtualAlexa { }).catch(error => { callback(error, null, request); }); - BstStatistics.instance().record(BstCommand.intend, undefined, this.nodeId); + BstStatistics.instance().record(BstCommand.intend, undefined, this.nodeId, Global.version()); return this; } @@ -264,7 +264,7 @@ export class BSTVirtualAlexa { callback(error, null, request); }); - BstStatistics.instance().record(BstCommand.launch, undefined, this.nodeId); + BstStatistics.instance().record(BstCommand.launch, undefined, this.nodeId, Global.version()); return this; } } diff --git a/lib/server/node-manager.ts b/lib/server/node-manager.ts index bfdf428a..81dc4bd4 100644 --- a/lib/server/node-manager.ts +++ b/lib/server/node-manager.ts @@ -56,7 +56,7 @@ export class NodeManager { } // Capture the connection - BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, node.id); + BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, node.id, Global.version()); } else if (strMessage === Global.KeepAliveMessage) { NodeManager.onKeepAliveReceived(node); diff --git a/lib/statistics/bst-statistics.ts b/lib/statistics/bst-statistics.ts index 91360ade..dbdff6b0 100644 --- a/lib/statistics/bst-statistics.ts +++ b/lib/statistics/bst-statistics.ts @@ -40,8 +40,8 @@ export class BstStatistics { clearInterval(this.timer); } - record(command: string, event?: string, nodeId?: string, flushed?: (error?: Error) => void) { - this.statisticsContext.record(command, event, nodeId); + record(command: string, event?: string, nodeId?: string, version?: string, flushed?: (error?: Error) => void) { + this.statisticsContext.record(command, event, nodeId, version); if (!this.timer) { this.statisticsContext.flush(flushed); } @@ -51,8 +51,8 @@ export class BstStatistics { export class StatisticsContext { private _queue: Array = []; - public record(command: string, event?: string, nodeId?: string) { - this._queue.push(new BstStat(command, event, nodeId)); + public record(command: string, event?: string, nodeId?: string, version?: string) { + this._queue.push(new BstStat(command, event, nodeId, version)); } public flush(flushed?: (error?: Error) => void) { @@ -123,7 +123,7 @@ export class StatisticsContext { export class BstStat { public _timestamp: Date; - public constructor(public command: string, public event?: string, public nodeId?: string) { + public constructor(public command: string, public event?: string, public nodeId?: string, version?: string) { this._timestamp = new Date(); } diff --git a/package-lock.json b/package-lock.json index bec04f5c..e72c9685 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1046,9 +1046,9 @@ } }, "browser-process-hrtime": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz", - "integrity": "sha1-Ql1opY00R/AqBKqJQYf86K+Le44=" + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", + "integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==" }, "browser-resolve": { "version": "1.11.3", @@ -9200,9 +9200,9 @@ } }, "skill-testing-ml": { - "version": "2.0.30", - "resolved": "https://registry.npmjs.org/skill-testing-ml/-/skill-testing-ml-2.0.30.tgz", - "integrity": "sha512-5+HFem3GAda4D+hvBS0HidKKVRRWYrSdzNRZz9zaStQddmSvYf3ZNFaUSWtyeby2iioJtZSug0QserVGl9K9ZA==", + "version": "0.5.30", + "resolved": "https://registry.npmjs.org/skill-testing-ml/-/skill-testing-ml-0.5.30.tgz", + "integrity": "sha512-qC1SOvBPj9bmL2ITzxX4czKS5tsggmmY353QFxbUPF5+lJG+hmsMDwnfN0VDXrBeThPMbv9rCXCmqxzCrV8yUQ==", "requires": { "chalk": "^2.4.1", "cosmiconfig": "^5.0.5", diff --git a/test/statistics/bst-statistics-test.ts b/test/statistics/bst-statistics-test.ts index 588ccf1f..4488bfc8 100644 --- a/test/statistics/bst-statistics-test.ts +++ b/test/statistics/bst-statistics-test.ts @@ -28,7 +28,7 @@ describe("BstStatistics", function() { return {bstStats: requestBody.bstStats.length}; }); - BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, undefined, function(error) { + BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, undefined, "2.0.0", function(error) { assert(!error); done(); }); @@ -42,7 +42,7 @@ describe("BstStatistics", function() { }) .replyWithError("something bad happened"); - BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, undefined, function(error) { + BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, undefined, "2.0.0", function(error) { assert(error); done(); }); From 5fcf5c7b5bee04a0a1c7dd76da8dfd9861bf515a Mon Sep 17 00:00:00 2001 From: Juan Perata Date: Wed, 26 Sep 2018 02:02:12 -0500 Subject: [PATCH 2/3] Statistic changes --- lib/client/bst-proxy.ts | 3 +++ lib/statistics/bst-statistics.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/client/bst-proxy.ts b/lib/client/bst-proxy.ts index 0b8db362..f0b79c2a 100644 --- a/lib/client/bst-proxy.ts +++ b/lib/client/bst-proxy.ts @@ -5,6 +5,8 @@ import {Global} from "../core/global"; import {BSTConfig} from "./bst-config"; import {FunctionServer} from "./function-server"; import {LoggingHelper} from "../core/logging-helper"; +import {BstStatistics, BstCommand} from "../statistics/bst-statistics"; + export enum ProxyType { GOOGLE_CLOUD_FUNCTION, @@ -163,6 +165,7 @@ export class BSTProxy { this.functionServer.start(callback); } + BstStatistics.instance().record(BstCommand.proxy, undefined, Global.config().secretKey(), Global.version()); return this; } diff --git a/lib/statistics/bst-statistics.ts b/lib/statistics/bst-statistics.ts index dbdff6b0..9aa9e179 100644 --- a/lib/statistics/bst-statistics.ts +++ b/lib/statistics/bst-statistics.ts @@ -123,7 +123,7 @@ export class StatisticsContext { export class BstStat { public _timestamp: Date; - public constructor(public command: string, public event?: string, public nodeId?: string, version?: string) { + public constructor(public command: string, public event?: string, public nodeId?: string, public version?: string) { this._timestamp = new Date(); } From 27ae69098419338e5f233cb9d074e23e13a83c58 Mon Sep 17 00:00:00 2001 From: Juan Perata Date: Wed, 26 Sep 2018 02:09:58 -0500 Subject: [PATCH 3/3] Remove server global.version that is not existant --- lib/server/node-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/node-manager.ts b/lib/server/node-manager.ts index 81dc4bd4..bfdf428a 100644 --- a/lib/server/node-manager.ts +++ b/lib/server/node-manager.ts @@ -56,7 +56,7 @@ export class NodeManager { } // Capture the connection - BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, node.id, Global.version()); + BstStatistics.instance().record(BstCommand.proxy, BstEvent.connect, node.id); } else if (strMessage === Global.KeepAliveMessage) { NodeManager.onKeepAliveReceived(node);