appdynamics
Version:
Performance Profiler and Monitor
42 lines (35 loc) • 1.08 kB
JavaScript
/*
Copyright (c) AppDynamics, Inc., and its affiliates
2015
All Rights Reserved
*/
;
var GrpcEntryProbe = require('./grpc-entry-probe').GrpcEntryProbe;
var GrpcExitProbe = require('./grpc-exit-probe').GrpcExitProbe;
function GrpcProbe(agent) {
this.agent = agent;
this.packages = ['@grpc/grpc-js'];
this.entryProbe = new GrpcEntryProbe(agent);
this.exitProbe = new GrpcExitProbe(agent);
this.init();
}
exports.GrpcProbe = GrpcProbe;
GrpcProbe.prototype.init = function() {
this.entryProbe.init();
this.exitProbe.init();
};
GrpcProbe.prototype.attach = function(obj, moduleName) {
var self = this;
var proxy = this.agent.proxy;
if(obj.__appdynamicsProbeAttached__) return;
obj.__appdynamicsProbeAttached__ = true;
self.agent.on('destroy', function() {
if(obj.__appdynamicsProbeAttached__) {
delete obj.__appdynamicsProbeAttached__;
proxy.release(obj.Server.prototype.register);
proxy.release(obj.loadPackageDefinition);
}
});
this.entryProbe.attach(obj, moduleName);
this.exitProbe.attach(obj, moduleName);
};