diff --git a/x-pack/plugins/reporting/server/routes/common/jobs/get_document_payload.ts b/x-pack/plugins/reporting/server/routes/common/jobs/get_document_payload.ts index d8a0027c42d644..c77e04ec66c22e 100644 --- a/x-pack/plugins/reporting/server/routes/common/jobs/get_document_payload.ts +++ b/x-pack/plugins/reporting/server/routes/common/jobs/get_document_payload.ts @@ -54,6 +54,8 @@ const getReportingHeaders = (output: TaskRunResult, exportType: ExportType) => { }; export function getDocumentPayloadFactory(reporting: ReportingCore) { + const { logger: _logger } = reporting.getPluginSetupDeps(); + const logger = _logger.get('download-report'); const exportTypesRegistry = reporting.getExportTypesRegistry(); async function getCompleted({ @@ -88,6 +90,8 @@ export function getDocumentPayloadFactory(reporting: ReportingCore) { const jobsQuery = jobsQueryFactory(reporting); const error = await jobsQuery.getError(id); + logger.debug(`Report job ${id} has failed. Sending statusCode: 500`); + return { statusCode: 500, content: { @@ -98,7 +102,9 @@ export function getDocumentPayloadFactory(reporting: ReportingCore) { }; } - function getIncomplete({ status }: ReportApiJSON): Payload { + function getIncomplete({ id, status }: ReportApiJSON): Payload { + logger.debug(`Report job ${id} is processing. Sending statusCode: 503`); + return { statusCode: 503, content: status,