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),
|
timeoutLimitsMiddleware(this.metadataBackend),
|
||||||
validateCopyQuery(),
|
validateCopyQuery(),
|
||||||
handleCopyFrom(),
|
handleCopyFrom(),
|
||||||
responseCopyFrom(),
|
responseCopyFrom(this.statsClient),
|
||||||
errorMiddleware()
|
errorMiddleware()
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
@ -149,25 +149,22 @@ function handleCopyFrom () {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function responseCopyFrom () {
|
function responseCopyFrom (statsClient) {
|
||||||
return function responseCopyFromMiddleware (req, res, next) {
|
return function responseCopyFromMiddleware (req, res, next) {
|
||||||
if (!res.body || !res.body.total_rows) {
|
if (!res.body || !res.body.total_rows) {
|
||||||
return next(new Error("No rows copied"));
|
return next(new Error("No rows copied"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.profiler) {
|
const metrics = {
|
||||||
const copyFromMetrics = {
|
size: res.locals.copyFromSize, //bytes
|
||||||
size: res.locals.copyFromSize, //bytes
|
format: getFormatFromCopyQuery(req.query.q),
|
||||||
format: getFormatFromCopyQuery(req.query.q),
|
time: res.body.time, //seconds
|
||||||
time: res.body.time, //seconds
|
total_rows: res.body.total_rows,
|
||||||
total_rows: res.body.total_rows,
|
gzip: req.get('content-encoding') === 'gzip'
|
||||||
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);
|
res.send(res.body);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -184,7 +181,7 @@ function validateCopyQuery () {
|
|||||||
if (!sql.toUpperCase().startsWith("COPY ")) {
|
if (!sql.toUpperCase().startsWith("COPY ")) {
|
||||||
next(new Error("SQL must start with COPY"));
|
next(new Error("SQL must start with COPY"));
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user