Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Reporting] Add a bit more logging and a few more logging level promotions #43415

Merged
merged 1 commit into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import * as Rx from 'rxjs';
import { i18n } from '@kbn/i18n';
import { mergeMap, catchError, map, takeUntil } from 'rxjs/operators';
import { oncePerServer } from '../../../../server/lib/once_per_server';
import { oncePerServer } from '../../../../server/lib';
import { generatePngObservableFactory } from '../lib/generate_png';
import {
decryptJobHeaders,
Expand Down Expand Up @@ -45,7 +45,8 @@ function executeJobFn(server) {
content_type: 'image/png',
content: buffer.toString('base64'),
size: buffer.byteLength,
}))
})),
catchError(err => Rx.throwError(err))
);

const stop$ = Rx.fromEventPattern(cancellationToken.on);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import * as Rx from 'rxjs';
import { mergeMap, catchError, map, takeUntil } from 'rxjs/operators';
import { i18n } from '@kbn/i18n';
import { oncePerServer } from '../../../../server/lib/once_per_server';
import { oncePerServer } from '../../../../server/lib';
import { generatePdfObservableFactory } from '../lib/generate_pdf';
import { compatibilityShimFactory } from './compatibility_shim';
import {
Expand Down Expand Up @@ -55,7 +55,8 @@ function executeJobFn(server) {
content_type: 'application/pdf',
content: buffer.toString('base64'),
size: buffer.byteLength,
}))
})),
catchError(err => Rx.throwError(err))
);

const stop$ = Rx.fromEventPattern(cancellationToken.on);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,5 @@ import { HeadlessChromiumDriverFactory } from './driver_factory';
export { paths } from './paths';

export async function createDriverFactory(binaryPath, logger, browserConfig, queueTimeout) {
if (browserConfig.disableSandbox) {
logger.warning(`Enabling the Chromium sandbox provides an additional layer of protection.`);
}

return new HeadlessChromiumDriverFactory(binaryPath, logger, browserConfig, queueTimeout);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,17 @@ export async function createBrowserDriverFactory(server: KbnServer) {
const BROWSER_CONFIG = CAPTURE_CONFIG.browser[BROWSER_TYPE];
const REPORTING_TIMEOUT = config.get('xpack.reporting.queue.timeout');

if (BROWSER_CONFIG.disableSandbox) {
logger.warning(`Enabling the Chromium sandbox provides an additional layer of protection.`);
}
if (BROWSER_AUTO_DOWNLOAD) {
await ensureBrowserDownloaded(BROWSER_TYPE);
}

try {
const browser = BROWSERS_BY_TYPE[BROWSER_TYPE];
const browser = BROWSERS_BY_TYPE[BROWSER_TYPE]; // NOTE: unecessary indirection: this is always a Chromium browser object, as of PhantomJS removal
const { binaryPath } = await installBrowser(logger, browser, DATA_DIR);
const browserDriverFactory = browser.createDriverFactory(
binaryPath,
logger,
BROWSER_CONFIG,
REPORTING_TIMEOUT
);
logger.debug(`Browser installed at ${browserDriverFactory.binaryPath}`);
return browserDriverFactory;
return browser.createDriverFactory(binaryPath, logger, BROWSER_CONFIG, REPORTING_TIMEOUT);
} catch (error) {
if (error.cause && ['EACCES', 'EEXIST'].includes(error.cause.code)) {
logger.error(
Expand Down
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/reporting/server/browsers/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export async function installBrowser(
await chmod(binaryPath, '755');
}

logger.debug(`Browser installed at ${binaryPath}`);
return {
binaryPath,
};
Expand Down
5 changes: 3 additions & 2 deletions x-pack/legacy/plugins/reporting/server/lib/enqueue_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ function enqueueJobFn(server) {
const browserType = config.get('xpack.reporting.capture.browser.type');
const exportTypesRegistry = server.plugins.reporting.exportTypesRegistry;

return async function enqueueJob(exportTypeId, jobParams, user, headers, request) {
return async function enqueueJob(parentLogger, exportTypeId, jobParams, user, headers, request) {
const logger = parentLogger.clone(['queue-job']);
const exportType = exportTypesRegistry.getById(exportTypeId);
const createJob = exportType.createJobFactory(server);
const payload = await createJob(jobParams, headers, request);
Expand All @@ -31,7 +32,7 @@ function enqueueJobFn(server) {

job.on(esqueueEvents.EVENT_JOB_CREATED, (createdJob) => {
if (createdJob.id === job.id) {
server.log(['reporting', 'esqueue', 'info'], `Successfully queued job: ${createdJob.id}`);
logger.info(`Successfully queued job: ${createdJob.id}`);
resolve(job);
}
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/reporting/server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function registerRoutes(server: KbnServer, logger: Logger) {
const user = request.pre.user;
const headers = request.headers;

const job = await enqueueJob(exportTypeId, jobParams, user, headers, request);
const job = await enqueueJob(logger, exportTypeId, jobParams, user, headers, request);

// return the queue's job information
const jobJson = job.toJSON();
Expand Down