appmetrics
appmetrics copied to clipboard
appmetrics not working with mysql when using pool requests
I am using appmetrics to monitor mysql changes and even though my application is performing mysql queries, I am not getting any data back.
var appmetrics = require('appmetrics')
var monitoring = appmetrics.monitor();
monitoring.on("mysql", function (data) {
console.log(data);
});
I am using a db pool also, could this be an issue? Is there a workaround? Thanks
@chumberi Which npm module are you using for your mysql queries ?
@tobespc const mysql = require('mysql');
@chumberi is your require('appmetrics') statement before your require('mysql') statement? If it's not, move your require('appmetrics') statement to the top of the file - Appmetrics instruments modules at the point when the modules are required, so it needs to be loaded first.
@mattcolegate yes, unfortunately, my require('appmetrics') is before my require('mysql') statement and its still not working...
@chumberi any chance you could share the top half of your code where you are doing the requires ?
@tobespc yup, no problem:
var appmetrics = require('appmetrics')
var monitoring = appmetrics.monitor();
var metrics = ['http','http-outbound','cpu','gc','eventloop','loop','memcached','memory','mysql'];
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const session = require('express-session');
const mysql = require('mysql');
@jamesemwallis Could you pick this up please and try and get a recreate scenario, thanks
@chumberi I have SQL data being emitted with the following simple test case.
Does this simple app work in your environment? Could you share an example query that you are doing which should be getting data back as well please.
Thanks
global.db_pool = mysql.createPool(config.dbDetails('write'));
query = QUERY;
global.db_pool.getConnection(function(err, connection) { connection.query(query, data, function(err, rows, fields) { }) });
I have recreated the problem and am looking into it now.
@chumberi I have been investigating the issue which is mysql pools.
We do not currently support this but I will raise it as an enhancement request for the future.
Thanks.
Has there been any update on this enhancement?
@chumberi we don't have any immediate plans to implement this but we are open to pull requests if you are interested in taking a look yourself.
Hey guys, any update or workaround on this enhancement?
Any update on this?