|
|
const InfluxSender = require('influx-batch-sender');
|
|
|
const alipayService = require('./alipay.service');
|
|
|
const { logger, config } = global.yoho;
|
|
|
|
|
|
/**
|
|
|
* 统计成功注册的用户数, 使用 APM db
|
|
|
*/
|
|
|
const monitor = new InfluxSender({
|
|
|
...config.report,
|
|
|
measurement: 'alipay-register-count',
|
|
|
duration: 1 * 60 * 1000, // 1m
|
|
|
immediate: false,
|
|
|
});
|
|
|
|
|
|
monitor.on('sendError', e => {
|
|
|
logger.error('alipay send monitor info', e);
|
|
|
});
|
|
|
|
|
|
monitor.on('failed', statusCode => {
|
|
|
logger.warn('alipay send monitor info', statusCode);
|
|
|
});
|
|
|
|
|
|
// monitor tags
|
|
|
const tags = {
|
|
|
appName: config.appName,
|
|
|
host: require('os').hostname(),
|
|
|
pid: process.pid,
|
|
|
};
|
|
|
|
|
|
function submit(req, res, next) {
|
|
|
const { alipayAccount, alipayName } = req.body;
|
...
|
...
|
@@ -16,6 +43,19 @@ function submit(req, res, next) { |
|
|
return res.json(result.error);
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
monitor.addMessage({
|
|
|
tags,
|
|
|
fields: {
|
|
|
uid,
|
|
|
ip: req.yoho.clientIp,
|
|
|
udid: req.yoho.udid
|
|
|
}
|
|
|
});
|
|
|
} catch (e) {
|
|
|
logger.error('alipay send monitor info, addMessage', e);
|
|
|
}
|
|
|
|
|
|
return res.json(result);
|
|
|
}).catch(next);
|
|
|
}
|
...
|
...
|
|