Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongnansu committed Dec 30, 2020
1 parent d4598bc commit e2323d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
10 changes: 5 additions & 5 deletions kibana-reports/server/routes/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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: {
Expand All @@ -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);
}
}
Expand Down
8 changes: 8 additions & 0 deletions kibana-reports/server/routes/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export const GLOBAL_BASIC_COUNTER: CountersType = {
create: {
total: 0,
},
create_from_definition: {
total: 0,
},
download: {
total: 0,
},
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion kibana-reports/server/routes/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export type ActionType =
| 'delete'
| 'create'
| 'download'
| 'update';
| 'update'
| 'create_from_definition';

export type CountersType = ActionCountersType & UsageCountersType;

Expand Down

0 comments on commit e2323d6

Please sign in to comment.