From 54137d5f149f9cf0ab585a194d919d41a16280e9 Mon Sep 17 00:00:00 2001 From: Evgeny Smyshlyaev Date: Sat, 19 Jan 2019 18:30:18 +0300 Subject: [PATCH] improve logging (#344) improve analytic's logging about incoming task, logging on server side about incoming detection results --- analytics/bin/server | 10 +++++----- server/src/controllers/analytics_controller.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/analytics/bin/server b/analytics/bin/server index 4ef262f..8fb5bb7 100755 --- a/analytics/bin/server +++ b/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) diff --git a/server/src/controllers/analytics_controller.ts b/server/src/controllers/analytics_controller.ts index 3540abb..1cfce9b 100644 --- a/server/src/controllers/analytics_controller.ts +++ b/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,