ApplicationInsights-node.js/Tests/AutoCollection/NativePerformance.tests.ts

149 строки
8.0 KiB
TypeScript
Исходник Постоянная ссылка Обычный вид История

add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
import assert = require("assert");
import sinon = require("sinon");
import AppInsights = require("../../applicationinsights");
import TelemetryClient = require("../../Library/TelemetryClient");
import { AutoCollectNativePerformance } from "../../AutoCollection/NativePerformance";
import { JsonConfig } from "../../Library/JsonConfig";
import * as Constants from "../../Declarations/Constants";
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
const ENV_nativeMetricsDisablers = "APPLICATION_INSIGHTS_DISABLE_EXTENDED_METRIC";
const ENV_nativeMetricsDisableAll = "APPLICATION_INSIGHTS_DISABLE_ALL_EXTENDED_METRICS";
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
describe("AutoCollection/NativePerformance", () => {
var sandbox: sinon.SinonSandbox;
beforeEach(() => {
sandbox = sinon.sandbox.create();
JsonConfig["_instance"] = undefined;
});
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
afterEach(() => {
AppInsights.dispose();
sandbox.restore();
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
});
describe("#init and #dispose()", () => {
it("init should enable and dispose should stop autocollection interval", () => {
var setIntervalSpy = sandbox.spy(global, "setInterval");
var clearIntervalSpy = sandbox.spy(global, "clearInterval");
const statsAddSpy = sandbox.spy(AutoCollectNativePerformance.INSTANCE["_statsbeat"], "addFeature");
const statsRemoveSpy = sandbox.spy(AutoCollectNativePerformance.INSTANCE["_statsbeat"], "removeFeature");
AppInsights.setup("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333")
.setAutoCollectHeartbeat(false)
.setAutoCollectPerformance(false, true)
.setAutoCollectPreAggregatedMetrics(false)
.start();
if (AutoCollectNativePerformance["_metricsAvailable"]) {
assert.ok(statsAddSpy.calledOnce);
assert.strictEqual(AutoCollectNativePerformance.INSTANCE["_statsbeat"]["_feature"], Constants.StatsbeatFeature.NATIVE_METRICS + Constants.StatsbeatFeature.DISK_RETRY);
assert.equal(setIntervalSpy.callCount, 3, "setInteval should be called three times as part of NativePerformance initialization as well as Statsbeat");
AppInsights.dispose();
assert.ok(statsRemoveSpy.calledOnce);
assert.strictEqual(AutoCollectNativePerformance.INSTANCE["_statsbeat"]["_feature"], Constants.StatsbeatFeature.DISK_RETRY);
assert.equal(clearIntervalSpy.callCount, 1, "clearInterval should be called once as part of NativePerformance shutdown");
} else {
assert.equal(setIntervalSpy.callCount, 2, "setInterval should not be called if NativePerformance package is not available, Statsbeat will be called");
AppInsights.dispose();
assert.equal(clearIntervalSpy.callCount, 0, "clearInterval should not be called if NativePerformance package is not available");
}
});
it("constructor should be safe to call multiple times", () => {
var client = new TelemetryClient("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333");
var native = new AutoCollectNativePerformance(client);
var sinonSpy = sandbox.spy(AutoCollectNativePerformance.INSTANCE, "dispose");
assert.ok(native);
assert.ok(sinonSpy.notCalled);
assert.doesNotThrow(() => { native = new AutoCollectNativePerformance(client) }, "NativePerformance can be constructed more than once");
assert.ok(sinonSpy.calledOnce, "dispose is called when second instance is constructed");
});
it("Calling enable multiple times should not create multiple timers", () => {
var client = new TelemetryClient("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333");
var sinonSpy = sandbox.spy(global, "setInterval");
var native = new AutoCollectNativePerformance(client);
assert.ok(native);
assert.doesNotThrow(() => native.enable(true), "Does not throw when trying to enable");
assert.doesNotThrow(() => native.enable(true), "Does not throw when trying to enable");
if (AutoCollectNativePerformance["_metricsAvailable"]) {
assert.equal(sinonSpy.callCount, 1, "setInterval should be singleton");
}
else{
assert.equal(sinonSpy.callCount, 0, "setInterval should not be called if native metrics package is not installed");
}
});
it("Calling enable when metrics are not available should fail gracefully", () => {
var client = new TelemetryClient("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333");
var native = new AutoCollectNativePerformance(client);
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
AutoCollectNativePerformance["_metricsAvailable"] = false;
assert.ok(!(<any>native)["_emitter"]);
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
assert.doesNotThrow(() => native.enable(true), "Does not throw when native metrics are not available and trying to enable");
assert.doesNotThrow(() => native.enable(false), "Does not throw when native metrics are not available and trying to disable");
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
});
});
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
describe("#_parseEnabled", () => {
it("should return equal input arg if no env vars are set", () => {
const _customConfig = JsonConfig.getInstance();
assert.deepEqual(AutoCollectNativePerformance.parseEnabled(true, _customConfig), { isEnabled: true, disabledMetrics: {} });
assert.deepEqual(AutoCollectNativePerformance.parseEnabled(false, _customConfig), { isEnabled: false, disabledMetrics: {} });
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
const config = { gc: true, heap: true };
assert.deepEqual(AutoCollectNativePerformance.parseEnabled(config, _customConfig), { isEnabled: true, disabledMetrics: config });
});
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
it("should overwrite input arg if disable all extended metrics env var is set", () => {
const env = <{ [id: string]: string }>{};
const originalEnv = process.env;
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
env[ENV_nativeMetricsDisableAll] = "set";
process.env = env;
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
const _customConfig = JsonConfig.getInstance();
assert.deepEqual(AutoCollectNativePerformance.parseEnabled(true, _customConfig), { isEnabled: false, disabledMetrics: {} });
assert.deepEqual(AutoCollectNativePerformance.parseEnabled({}, _customConfig), { isEnabled: false, disabledMetrics: {} });
assert.deepEqual(AutoCollectNativePerformance.parseEnabled({ gc: true }, _customConfig), { isEnabled: false, disabledMetrics: {} });
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
process.env = originalEnv;
});
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
it("should overwrite input arg if individual env vars are set", () => {
const expectation = { gc: true, heap: true };
const env = <{ [id: string]: string }>{};
const originalEnv = process.env;
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
env[ENV_nativeMetricsDisablers] = "gc,heap";
process.env = env;
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
const _customConfig = JsonConfig.getInstance();
let inConfig;
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
inConfig = false;
assert.deepEqual(AutoCollectNativePerformance.parseEnabled(inConfig, _customConfig), { isEnabled: false, disabledMetrics: expectation });
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
inConfig = true;
assert.deepEqual(AutoCollectNativePerformance.parseEnabled(inConfig, _customConfig), { isEnabled: true, disabledMetrics: expectation });
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
inConfig = {};
assert.deepEqual(AutoCollectNativePerformance.parseEnabled(inConfig, _customConfig), { isEnabled: true, disabledMetrics: expectation });
inConfig = { gc: true };
assert.deepEqual(AutoCollectNativePerformance.parseEnabled(inConfig, _customConfig), { isEnabled: true, disabledMetrics: expectation });
inConfig = { loop: true };
assert.deepEqual(AutoCollectNativePerformance.parseEnabled(inConfig, _customConfig), { isEnabled: true, disabledMetrics: { ...inConfig, ...expectation } });
inConfig = { gc: false, loop: true, heap: 'abc', something: 'else' };
assert.deepEqual(AutoCollectNativePerformance.parseEnabled(<any>inConfig, _customConfig), { isEnabled: true, disabledMetrics: { ...inConfig, ...expectation } });
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
process.env = originalEnv;
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
});
});
add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs
2019-05-29 02:49:45 +03:00
});