Browse Source

improve logging (#344)

improve analytic's logging about incoming task, logging on server side about incoming detection results
pull/1/head
Evgeny Smyshlyaev 6 years ago committed by GitHub
parent
commit
54137d5f14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      analytics/bin/server
  2. 10
      server/src/controllers/analytics_controller.ts

10
analytics/bin/server

@ -40,24 +40,24 @@ root.addHandler(logging_handler)
async def handle_task(task: object):
try:
logger.info("Command is OK")
task_type = task['type']
logger.info("Got {} task with id {}, analyticUnitId {}".format(task_type, task['_id'], task['analyticUnitId']))
task_result_payload = {
'_id': task['_id'],
'task': task['type'],
'task': task_type,
'analyticUnitId': task['analyticUnitId'],
'status': "IN_PROGRESS"
}
if not task['type'] == 'PUSH':
if not task_type == 'PUSH':
message = services.server_service.ServerMessage('TASK_RESULT', task_result_payload)
await server_service.send_message(message)
res = await analytic_unit_manager.handle_analytic_task(task)
res['_id'] = task['_id']
if not task['type'] == 'PUSH':
if not task_type == 'PUSH':
message = services.server_service.ServerMessage('TASK_RESULT', res)
await server_service.send_message(message)

10
server/src/controllers/analytics_controller.ts

@ -299,6 +299,7 @@ async function processDetectionResult(analyticUnitId: AnalyticUnit.AnalyticUnitI
`Missing lastDetectionTime in result or it is corrupted: ${JSON.stringify(detectionResult)}`
);
}
console.debug(`got detection result with ${detectionResult.segments.length} segments`);
const segments = detectionResult.segments.map(
segment => new Segment.Segment(analyticUnitId, segment.from, segment.to, false, false)
@ -311,7 +312,14 @@ async function processDetectionResult(analyticUnitId: AnalyticUnit.AnalyticUnitI
console.error(`error while sending webhook: ${err.message}`);
}
} else {
console.debug(`skip sending webhook for ${analyticUnitId}`);
let reasons = [];
if(!analyticUnit.alert) {
reasons.push('alerting disabled');
}
if(_.isEmpty(segments)) {
reasons.push('segments empty');
}
console.debug(`skip sending webhook for ${analyticUnit.id}, ${reasons.join(', ')}`);
}
return {
lastDetectionTime: detectionResult.lastDetectionTime,

Loading…
Cancel
Save