From e2323d6a15198ff209f16447221e981171e85f09 Mon Sep 17 00:00:00 2001 From: Zhongnan Su Date: Tue, 29 Dec 2020 19:47:25 -0800 Subject: [PATCH] minor fix --- kibana-reports/server/routes/report.ts | 10 +++++----- kibana-reports/server/routes/utils/constants.ts | 8 ++++++++ kibana-reports/server/routes/utils/types.ts | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/kibana-reports/server/routes/report.ts b/kibana-reports/server/routes/report.ts index 43473db0..9244d712 100644 --- a/kibana-reports/server/routes/report.ts +++ b/kibana-reports/server/routes/report.ts @@ -60,7 +60,7 @@ export default function (router: IRouter) { report = reportSchema.validate(report); } catch (error) { logger.error(`Failed input validation for create report ${error}`); - addToMetric('report', 'create', 'user_error', report); + addToMetric('report', 'create', 'user_error'); return response.badRequest({ body: error }); } @@ -87,7 +87,7 @@ export default function (router: IRouter) { // TODO: better error handling for delivery and stages in generating report, pass logger to deeper level logger.error(`Failed to generate report: ${error}`); logger.error(error); - addToMetric('report', 'create', checkErrorType(error), report); + addToMetric('report', 'create', checkErrorType(error)); return errorResponse(response, error); } } @@ -147,7 +147,7 @@ export default function (router: IRouter) { } catch (error) { logger.error(`Failed to generate report by id: ${error}`); logger.error(error); - addToMetric('report', 'download', checkErrorType(error), report); + addToMetric('report', 'download', checkErrorType(error)); return errorResponse(response, error); } } @@ -200,7 +200,7 @@ export default function (router: IRouter) { report, reportId ); - addToMetric('report', 'create', 'count', report); + addToMetric('report', 'create_from_definition', 'count', report); return response.ok({ body: { @@ -213,7 +213,7 @@ export default function (router: IRouter) { `Failed to generate report from reportDefinition id ${reportDefinitionId} : ${error}` ); logger.error(error); - addToMetric('report', 'create', checkErrorType(error), report); + addToMetric('report', 'create_from_definition', checkErrorType(error)); return errorResponse(response, error); } } diff --git a/kibana-reports/server/routes/utils/constants.ts b/kibana-reports/server/routes/utils/constants.ts index beb9ddf0..325a8930 100644 --- a/kibana-reports/server/routes/utils/constants.ts +++ b/kibana-reports/server/routes/utils/constants.ts @@ -93,6 +93,9 @@ export const GLOBAL_BASIC_COUNTER: CountersType = { create: { total: 0, }, + create_from_definition: { + total: 0, + }, download: { total: 0, }, @@ -165,6 +168,11 @@ export const DEFAULT_ROLLING_COUNTER: CountersType = { system_error: 0, user_error: 0, }, + create_from_definition: { + count: 0, + system_error: 0, + user_error: 0, + }, download: { count: 0, system_error: 0, diff --git a/kibana-reports/server/routes/utils/types.ts b/kibana-reports/server/routes/utils/types.ts index 6e7d1d75..22f89284 100644 --- a/kibana-reports/server/routes/utils/types.ts +++ b/kibana-reports/server/routes/utils/types.ts @@ -35,7 +35,8 @@ export type ActionType = | 'delete' | 'create' | 'download' - | 'update'; + | 'update' + | 'create_from_definition'; export type CountersType = ActionCountersType & UsageCountersType;