@instana/shared-metrics
Version:
Internal metrics plug-in package for Node.js monitoring with Instana
33 lines (26 loc) • 713 B
JavaScript
/*
* (c) Copyright IBM Corp. 2021
* (c) Copyright Instana Inc. and contributors 2015
*/
;
exports.payloadPrefix = 'memory';
// @ts-ignore
exports.currentPayload = {};
/** @type {NodeJS.Timeout } */
let activeIntervalHandle = null;
exports.activate = function activate() {
gatherMemoryUsageStatistics();
activeIntervalHandle = setInterval(gatherMemoryUsageStatistics, 1000);
activeIntervalHandle.unref();
};
function gatherMemoryUsageStatistics() {
// @ts-ignore
exports.currentPayload = process.memoryUsage();
}
exports.deactivate = function deactivate() {
// @ts-ignore
exports.currentPayload = {};
if (activeIntervalHandle) {
clearInterval(activeIntervalHandle);
}
};