appmetrics icon indicating copy to clipboard operation
appmetrics copied to clipboard

appmetrics not working with mysql when using pool requests

Open chumberi opened this issue 8 years ago • 15 comments

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 avatar Jul 27 '17 11:07 chumberi

@chumberi Which npm module are you using for your mysql queries ?

tobespc avatar Jul 27 '17 12:07 tobespc

@tobespc const mysql = require('mysql');

chumberi avatar Jul 27 '17 12:07 chumberi

@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 avatar Jul 27 '17 12:07 mattcolegate

@mattcolegate yes, unfortunately, my require('appmetrics') is before my require('mysql') statement and its still not working...

chumberi avatar Jul 27 '17 12:07 chumberi

@chumberi any chance you could share the top half of your code where you are doing the requires ?

tobespc avatar Jul 27 '17 13:07 tobespc

@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');

chumberi avatar Jul 27 '17 13:07 chumberi

@jamesemwallis Could you pick this up please and try and get a recreate scenario, thanks

tobespc avatar Jul 31 '17 08:07 tobespc

@chumberi I have SQL data being emitted with the following simple test case.

app.js.zip

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

james-wallis avatar Jul 31 '17 10:07 james-wallis

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) { }) });

chumberi avatar Jul 31 '17 10:07 chumberi

I have recreated the problem and am looking into it now.

james-wallis avatar Jul 31 '17 12:07 james-wallis

@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.

james-wallis avatar Jul 31 '17 16:07 james-wallis

Has there been any update on this enhancement?

chumberi avatar Jul 25 '18 15:07 chumberi

@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.

sjanuary avatar Aug 13 '18 10:08 sjanuary

Hey guys, any update or workaround on this enhancement?

brenovieira avatar Apr 29 '19 13:04 brenovieira

Any update on this?

RedSpid3r avatar Aug 13 '21 20:08 RedSpid3r