From 105baf482423826863c8577fcb7c28f9a4faa199 Mon Sep 17 00:00:00 2001 From: Tim Sullivan Date: Mon, 20 May 2024 13:29:10 -0700 Subject: [PATCH] [Reporting] Download report: add debug logging around sending of 5xx codes (#183852) ## Summary These logs help correlate errors one may see from investigating HTTP 5xx status codes that are sent in response to the Download Report API. Related to: https://github.com/elastic/kibana/issues/183846 --- .../server/routes/common/jobs/get_document_payload.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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,