UNPKG

ca-apm-probe

Version:

CA APM Node.js Agent monitors real-time health and performance of Node.js applications

87 lines (70 loc) 2.49 kB
/** * Copyright (c) 2015 CA. All rights reserved. * * This software and all information contained therein is confidential and proprietary and * shall not be duplicated, used, disclosed or disseminated in any way except as authorized * by the applicable license agreement, without the express written permission of CA. All * authorized reproductions must be marked with this language. * * EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO THE EXTENT * PERMITTED BY APPLICABLE LAW, CA PROVIDES THIS SOFTWARE WITHOUT WARRANTY * OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL CA BE * LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR DAMAGE, DIRECT OR * INDIRECT, FROM THE USE OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, LOST * PROFITS, BUSINESS INTERRUPTION, GOODWILL, OR LOST DATA, EVEN IF CA IS * EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE. */ /** * CollectorMsg : send and receive messages with collector about modules */ var util = require('util'); var events = require("events"); function CollectorMsg() { events.EventEmitter.call(this); } util.inherits(CollectorMsg, events.EventEmitter); var collectormsg = new CollectorMsg(); module.exports = collectormsg; // Send require message to collector function sendRequireEvent(moduleName, args) { if (args == null) { args = new Object(); } createRequireEvent('send-require', moduleName, args); // return ctx } function receiveRequireEventResponse(moduleName, args) { if (args == null) { args= {}; } createRequireEvent('receive-require', moduleName, args); // return ctx } function createRequireEvent(evtType, moduleName, evtArgs) { var object = { module: moduleName }; if (evtArgs != null) { object.params = evtArgs; } collectormsg.emit(evtType, object); } function repostRequireEvent(event) { collectormsg.emit('send-require', event); } // we should handle the collector.on('receive-require'..) here or the handle should be here function receiveRequire(event) { // this should do the actual call into the monkey patching code based on the // response } function sendMetricEvent(metric) { collectormsg.emit('send-metric', metric); } module.exports.sendRequireEvent = sendRequireEvent; module.exports.receiveRequireEventResponse = receiveRequireEventResponse; module.exports.repostRequireEvent = repostRequireEvent; module.exports.sendMetricEvent = sendMetricEvent;