log query and job endpoints
This commit is contained in:
parent
2c1ce33e34
commit
2066115002
@ -11,6 +11,7 @@ const errorMiddleware = require('../middlewares/error');
|
|||||||
const rateLimitsMiddleware = require('../middlewares/rate-limit');
|
const rateLimitsMiddleware = require('../middlewares/rate-limit');
|
||||||
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitsMiddleware;
|
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitsMiddleware;
|
||||||
const handleQueryMiddleware = require('../middlewares/handle-query');
|
const handleQueryMiddleware = require('../middlewares/handle-query');
|
||||||
|
const logMiddleware = require('../middlewares/log');
|
||||||
|
|
||||||
function JobController(metadataBackend, userDatabaseService, jobService, statsdClient, userLimitsService) {
|
function JobController(metadataBackend, userDatabaseService, jobService, statsdClient, userLimitsService) {
|
||||||
this.metadataBackend = metadataBackend;
|
this.metadataBackend = metadataBackend;
|
||||||
@ -44,6 +45,7 @@ JobController.prototype.route = function (app) {
|
|||||||
bodyParserMiddleware(),
|
bodyParserMiddleware(),
|
||||||
checkBodyPayloadSize(),
|
checkBodyPayloadSize(),
|
||||||
handleQueryMiddleware(true),
|
handleQueryMiddleware(true),
|
||||||
|
logMiddleware(),
|
||||||
jobMiddlewares('create', createJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_CREATE)
|
jobMiddlewares('create', createJob, RATE_LIMIT_ENDPOINTS_GROUPS.JOB_CREATE)
|
||||||
);
|
);
|
||||||
app.get(
|
app.get(
|
||||||
|
@ -21,6 +21,7 @@ const { initializeProfilerMiddleware } = require('../middlewares/profiler');
|
|||||||
const rateLimitsMiddleware = require('../middlewares/rate-limit');
|
const rateLimitsMiddleware = require('../middlewares/rate-limit');
|
||||||
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitsMiddleware;
|
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitsMiddleware;
|
||||||
const handleQueryMiddleware = require('../middlewares/handle-query');
|
const handleQueryMiddleware = require('../middlewares/handle-query');
|
||||||
|
const logMiddleware = require('../middlewares/log');
|
||||||
|
|
||||||
var ONE_YEAR_IN_SECONDS = 31536000; // 1 year time to live by default
|
var ONE_YEAR_IN_SECONDS = 31536000; // 1 year time to live by default
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ QueryController.prototype.route = function (app) {
|
|||||||
connectionParamsMiddleware(this.userDatabaseService),
|
connectionParamsMiddleware(this.userDatabaseService),
|
||||||
timeoutLimitsMiddleware(this.metadataBackend),
|
timeoutLimitsMiddleware(this.metadataBackend),
|
||||||
handleQueryMiddleware(),
|
handleQueryMiddleware(),
|
||||||
|
logMiddleware(),
|
||||||
this.handleQuery.bind(this),
|
this.handleQuery.bind(this),
|
||||||
errorMiddleware()
|
errorMiddleware()
|
||||||
];
|
];
|
||||||
@ -241,6 +243,14 @@ QueryController.prototype.handleQuery = function (req, res, next) {
|
|||||||
if (dbopts.host) {
|
if (dbopts.host) {
|
||||||
res.header('X-Served-By-DB-Host', dbopts.host);
|
res.header('X-Served-By-DB-Host', dbopts.host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const logObj = {
|
||||||
|
request: {
|
||||||
|
sql: res.locals.sql
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.set('X-SQLAPI-Log', JSON.stringify(logObj));
|
||||||
|
|
||||||
formatter.sendResponse(opts, this);
|
formatter.sendResponse(opts, this);
|
||||||
},
|
},
|
||||||
function errorHandle(err){
|
function errorHandle(err){
|
||||||
|
Loading…
Reference in New Issue
Block a user