fix: add cdb-user field to data ingestion and batch queries logs

This commit is contained in:
Daniel García Aubert 2021-04-08 17:05:34 +02:00
parent 5cedad09c1
commit 53f69dd6e4
4 changed files with 6 additions and 6 deletions

View File

@ -102,10 +102,10 @@ function handleCopyTo ({ logger: mainLogger }) {
const pid = streamCopy.clientProcessID; const pid = streamCopy.clientProcessID;
streamCopy.cancel(pid, StreamCopy.ACTION_TO, (err) => { streamCopy.cancel(pid, StreamCopy.ACTION_TO, (err) => {
if (err) { if (err) {
return mainLogger.error({ request_id: requestId, exception: err, action: `copy-${StreamCopy.ACTION_TO}`, pid }, 'Unable to cancel stream query'); return mainLogger.error({ 'cdb-user': user, request_id: requestId, exception: err, action: `copy-${StreamCopy.ACTION_TO}`, pid }, 'Unable to cancel stream query');
} }
mainLogger.info({ request_id: requestId, action: `copy-${StreamCopy.ACTION_TO}`, pid }, 'Canceled stream query successfully'); mainLogger.info({ 'cdb-user': user, request_id: requestId, action: `copy-${StreamCopy.ACTION_TO}`, pid }, 'Canceled stream query successfully');
}); });
return next(err); return next(err);

View File

@ -140,7 +140,7 @@ function createJob (jobService) {
return next(err); return next(err);
} }
logger.info({ job: job.toJSON() }, 'Batch query job created'); logger.info({ 'cdb-user': res.locals.user, job: job.toJSON() }, 'Batch query job created');
res.statusCode = 201; res.statusCode = 201;
res.body = job.serialize(); res.body = job.serialize();

View File

@ -116,9 +116,9 @@ Batch.prototype.processJob = function (user, callback) {
} }
if (JobStatus.isFinal(job.data.status)) { if (JobStatus.isFinal(job.data.status)) {
self.logger.info({ job: job.toJSON() }, 'Batch query job finished'); self.logger.info({ 'cdb-user': user, job: job.toJSON() }, 'Batch query job finished');
} else { } else {
self.logger.debug({ job: job.toJSON() }, 'Batch query job: query done'); self.logger.debug({ 'cdb-user': user, job: job.toJSON() }, 'Batch query job: query done');
} }
return callback(null, !EMPTY_QUEUE); return callback(null, !EMPTY_QUEUE);

View File

@ -82,6 +82,6 @@ module.exports = class StreamCopyMetrics {
logData.success = this.success; logData.success = this.success;
this.logger.info({ ingestion: logData }, 'Copy to/from query metrics'); this.logger.info({ 'cdb-user': this.username, ingestion: logData }, 'Copy to/from query metrics');
} }
}; };