I just have started to integrate appdynamics to our server.
It's really great but some issues.
Our server stack is
- infra: AWS
- Web server: node.js
- cache - Redis (elasticache )
- database - mysql 5.6.x (RDS)
I can see web server and cache, but I cannot see mysql.
In addition, I cannot find out any sql query in business transaction snapshot.
Could you help me???
Hey there!
Could you share the Node.js library you are using to connect to RDS, as well as version number? This may be a limitation of our current instrumentation. I'll check with the dev team ASAP. If it should be supported, then we'll go down the path of checking some debug logs.
Best regards,
Kyle
Hi,
Thank you for response!!!!
I'm using node-mysql and version 0.9. (https://github.com/felixge/node-mysql/tree/v0.9 )
I'm using poolCulster as below.
var mysql = require('mysql');
var CryptoJS = require('crypto-js');
var clusterConfig = {
removeNodeErrorCount: 5,
defaultSelector: 'RR'
};
var poolCluster = mysql.createPoolCluster(clusterConfig);
var encryptedPassword = decryptPassword(Properties.password);
poolCluster.add('MASTER', {
host : Properties.masterHost,
port : Properties.port,
user : Properties.user,
password : encryptedPassword, //For security
database : Properties.database,
charset : Properties.charset,
connectTimeout : Properties.connectTimeout,
waitForConnections : Properties.waitForConnections,
connectionLimit : Properties.connectionLimit,
queueLimit : Properties.queueLimit,
debug : ['ComQueryPacket']
});
poolCluster.add('REPLICA1', {
host : Properties.replica1Host,
port : Properties.port,
user : Properties.user,
password : encryptedPassword, //For security
database : Properties.database,
charset : Properties.charset,
connectTimeout : Properties.connectTimeout,
waitForConnections : Properties.waitForConnections,
connectionLimit : Properties.connectionLimit,
queueLimit : Properties.queueLimit,
debug : ['ComQueryPacket']
});
poolCluster.add('REPLICA2', {
host : Properties.replica2Host,
port : Properties.port,
user : Properties.user,
password : encryptedPassword, //For security
database : Properties.database,
charset : Properties.charset,
connectTimeout : Properties.connectTimeout,
waitForConnections : Properties.waitForConnections,
connectionLimit : Properties.connectionLimit,
queueLimit : Properties.queueLimit,
debug : ['ComQueryPacket']
});
poolCluster.add('REPLICA3', {
host : Properties.replica3Host,
port : Properties.port,
user : Properties.user,
password : encryptedPassword, //For security
database : Properties.database,
charset : Properties.charset,
connectTimeout : Properties.connectTimeout,
waitForConnections : Properties.waitForConnections,
connectionLimit : Properties.connectionLimit,
queueLimit : Properties.queueLimit,
debug : ['ComQueryPacket']
});
var customQueryFormat = function (query, values) {
if (!values) return query;
return query.replace(/\#\{(\w+)\}/g, function (txt, key) {
logger.debug("txt : "+ txt + ", key : "+ key + ", val : "+values[key] + ", return: "+ this.escape(values[key]));
if (values.hasOwnProperty(key)) {
return this.escape(values[key]);
}
return txt;
}.bind(this));
};
//If can't connect to REPLICA1, return REPLICA2. (remove REPLICA1 in the cluster)
poolCluster.on('remove', function (nodeId) {
logger.debug('REMOVED NODE : ' + nodeId); // nodeId = REPLICA1
});
function keepAlive(){
poolCluster.getConnection('REPLICA*', function(err, connection) {
if(err) {
logger.error('### REPLICA* keepAlive error : '+ err);
return;
}
connection.ping();
connection.release();
//logger.debug("### REPLICA* keepAlive OK.");
});
poolCluster.getConnection('MASTER', function(err, connection) {
if(err) {
logger.error('### MASTER keepAlive error : '+ err);
return;
}
connection.ping();
connection.release();
//logger.debug("### MASTER keepAlive OK.");
});
}
setInterval(keepAlive, 60*1000);
// return writable connecton.
exports.getWConnection = function(callback){
return poolCluster.getConnection('MASTER', function(err, connection) {
if(err){
callback(err, null);
return;
}
if(!connection.binderr){
connection.on('error', function(err) {
logger.error('####### db connection error : '+ err);
});
connection.config.queryFormat = customQueryFormat;
connection.binderr = true;
}
callback(err, connection);
});
};
// return read only connection.
exports.getRConnection = function(callback){
return poolCluster.getConnection('REPLICA*', function(err, connection) {
if(err){
callback(err, null);
return;
}
logger.debug('getRConnection : ' + connection.config.host);
if(!connection.binderr){
connection.on('error', function(err) {
logger.debug('####### db connection error', err);
});
connection.config.queryFormat = customQueryFormat;
connection.binderr = true;
}
callback(err, connection);
});
};
exports.poolCluster = poolCluster;
-------------------------------------------------------
And I use getWConnection and getRconnection to get connection from pool as below.
DBCluster.getRConnection(function(err, connection){
if(err){
callback(err, null);
return;
}
connection.query(sql, queryParams, function(err, rows) {
.....