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,14 +149,13 @@ 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 = {
|
||||
const metrics = {
|
||||
size: res.locals.copyFromSize, //bytes
|
||||
format: getFormatFromCopyQuery(req.query.q),
|
||||
time: res.body.time, //seconds
|
||||
@ -164,9 +163,7 @@ function responseCopyFrom () {
|
||||
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