UNPKG

apminsight

Version:

monitor nodejs applications

48 lines (43 loc) 1.84 kB
var defaultThreshold = require("./threshold"); var libUtil = require("util"); const logger = require("./../util/logger"); const utils = require("./../util/utils"); function KeyTxnThreshold() { defaultThreshold.call(this); } libUtil.inherits(KeyTxnThreshold, defaultThreshold); function updateKeyTxnInfo(txnSpecificInfo) { if (txnSpecificInfo && (!Array.isArray(txnSpecificInfo) || txnSpecificInfo.length === 0)) { return; } txnSpecificInfo.forEach(function (eachTxnConfig) { if (!utils.isEmpty(eachTxnConfig)) { var txnName = eachTxnConfig.transactions; var txnConfigInfo = eachTxnConfig.config_info; try { var thresholdInstance = new defaultThreshold(); var newTH = JSON.parse(JSON.stringify(thresholdInstance)); if (!utils.isEmpty(newTH)) { Object.setPrototypeOf(newTH, Object.getPrototypeOf(thresholdInstance)); txnName.forEach(function (eachTxnName) { if (!utils.isEmpty(txnName) && !utils.isEmpty(txnConfigInfo)) { newTH._thresholdMap = Object.assign( newTH._thresholdMap, txnConfigInfo ); apmInsightAgentInstance._keyTxnThreshold[eachTxnName] = newTH; }else{ logger.warning(`either txnName: ${txnName} or it's txnConfigInfo are empty`); } }); } } catch (error) { logger.error("error while updating key transaction info ", error); } } }); } module.exports = { keyTxnThreshold: KeyTxnThreshold, updateKeyTxnInfo: updateKeyTxnInfo };