copyFrom metrics to statsd
This commit is contained in:
parent
30cb88c3f9
commit
6d73d97ae2
@ -36,7 +36,7 @@ CopyController.prototype.route = function (app) {
|
||||
timeoutLimitsMiddleware(this.metadataBackend),
|
||||
validateCopyQuery(),
|
||||
handleCopyFrom(),
|
||||
responseCopyFrom(),
|
||||
responseCopyFrom(this.statsClient),
|
||||
errorMiddleware()
|
||||
];
|
||||
};
|
||||
@ -149,24 +149,21 @@ function handleCopyFrom () {
|
||||
};
|
||||
}
|
||||
|
||||
function responseCopyFrom () {
|
||||
function responseCopyFrom (statsClient) {
|
||||
return function responseCopyFromMiddleware (req, res, next) {
|
||||
if (!res.body || !res.body.total_rows) {
|
||||
return next(new Error("No rows copied"));
|
||||
}
|
||||
|
||||
if (req.profiler) {
|
||||
const copyFromMetrics = {
|
||||
size: res.locals.copyFromSize, //bytes
|
||||
format: getFormatFromCopyQuery(req.query.q),
|
||||
time: res.body.time, //seconds
|
||||
total_rows: res.body.total_rows,
|
||||
gzip: req.get('content-encoding') === 'gzip'
|
||||
};
|
||||
const metrics = {
|
||||
size: res.locals.copyFromSize, //bytes
|
||||
format: getFormatFromCopyQuery(req.query.q),
|
||||
time: res.body.time, //seconds
|
||||
total_rows: res.body.total_rows,
|
||||
gzip: req.get('content-encoding') === 'gzip'
|
||||
};
|
||||
|
||||
req.profiler.add({ copyFrom: copyFromMetrics });
|
||||
res.header('X-SQLAPI-Profiler', req.profiler.toJSONString());
|
||||
}
|
||||
statsClient.set('copyFrom', JSON.stringify(metrics));
|
||||
|
||||
res.send(res.body);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user