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/Dashboard] Use Chromium for print-optimized PDFs #130546

Merged

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Apr 19, 2022

Summary

It is possible to request a "print-optimized" PDF from dashboard (our most popular app for making print-focussed reports). Today we use a native NPM dependency instead of Chromium for generating the PDF. We can improve performance of generating these PDFs by leveraging the print functionality native to browsers since we are already using headless Chromium.

Screenshots

Note: header and footers are included via puppeteers footerTemplate and headerTemplate (see their docs). Note: header is outdated in screenshot

Screenshot 2022-04-20 at 18 54 10

Samples

Benchmarks

See #130546 (comment)

Additional notes

  • Rework of [Screenshotting] PoC print media #128470
  • Needs benchmarks (CC @tsullivan )
  • Current implementation is server-side only, even though this does get us a lot closer to being able to printing client side, we still need to figure out how we want to handle headers/footers there.
  • Fix for missing time range in print-optimized PDF c3b5500

Checklist

Risk Matrix

Risk Probability Severity Mitigation/Notes
Introduce a performance regression. Low High Running benchmarks will help a lot with this. We are also taking fewer logical steps to create a PDF and not cloning/stringifying image buffers which should already greatly increase performance.

For maintainers

@jloleysens jloleysens added (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead release_note:skip Skip the PR/issue when compiling release notes Team:Reporting Services v8.3.0 labels Apr 19, 2022
@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@tsullivan
Copy link
Member

tsullivan commented Apr 19, 2022

Benchmark tests

These results used the three "print layout" tests from elastic/kibana-reporting-benchmarks repo.

The average execution time using the changes in this PR: 12.846 seconds
The average execution time baseline from the latest 8.3.0-SNAPSHOT build: 17.241 seconds.

Take a look at the dashboard set up from the logs of the test runs. The "Execution duration" chart is split by the server UUID: the blue line is the timings with a build of this PR, and the green line is the snapshot build.
image

The other stats: event loop delay, heap memory size, chromium memory size, etc. look virtually the same.

setup
VM size 8GB
Kibana max old space size 6.4GB

@jloleysens jloleysens changed the title [Reporting/Dashboard] Use Chromium to for print-optimized PDFs [Reporting/Dashboard] Use Chromium for print-optimized PDFs Apr 20, 2022
@jloleysens
Copy link
Contributor Author

If the styles of footers and headers is an issue we can consider using something like this: https://www.npmjs.com/package/puppeteer-report

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@jloleysens
Copy link
Contributor Author

jloleysens commented May 5, 2022

@tsullivan I think I've addressed your feedback:

  • Enable custom logos (see attached PDF in description)
  • Added the headless_shell/chromium-70f5d88-locales-linux_arm64.zip and headless_shell/chromium-70f5d88-locales-linux_x64.zip archives that contain the locales we need for the page numbers

we should also merge #131600 but I don't think we need to block this PR.

Would you mind taking another look?

log.info(
`expecting all time stats to report ${count} ${jobType} job types (actual: ${actual})`
);
expect(actual).to.be(count);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this test was such a pain. It's very old and was made before snapshots were a thing.

Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I have some percolating thoughts about calculating the page numbers of the PDF for telemetry, but let's save those for later.

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casing changes LGTM

Copy link
Contributor

@Heenawter Heenawter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code owner review - LGTM 👍

jloleysens and others added 2 commits May 9, 2022 11:04
…hromium-to-print-pdf-part-1

* 'main' of github.com:elastic/kibana: (59 commits)
  [Cloud Posture] Enabled findings group by feature (elastic#131780)
  [EBT] Fix `userId` generation (elastic#131701)
  [RAM] Add shareable rule tag filter (elastic#130710)
  Optimize package installation performance, phase 2 (elastic#131627)
  [Screenshotting] instrument for benchmark tests using new EventLogger class (elastic#130356)
  [Connector] Adding internal route for requesting ad-hoc ServiceNow access token (elastic#131171)
  [ci] bump kibana-buildkite-library (elastic#131754)
  [Synthetics] UI clean up (elastic#131598)
  [RsponseOps] Fix flaky rules list test (elastic#131567)
  [Cases] Add severity field to create case (elastic#131626)
  [Discover] Monospace font in Document Explorer (elastic#131513)
  Sessions tab improvements (elastic#131583)
  Add cloud icon "ess-icon" at the end of the config keys in "alerting" documentation (elastic#131735)
  [DOCS] Updates deprecation text for legacy APIs (elastic#131741)
  [ci] break out skip patterns so they can change without triggering CI (elastic#131726)
  Adjust search session management page font size (elastic#131291)
  [Unified search] Fix uptime css problem (elastic#131730)
  [Actionable Observability] Link to filtered rules page (elastic#131629)
  Add openAPI specifications for cases endpoint (elastic#131275)
  Display rule API key owner to users who can manage API keys (elastic#131662)
  ...

# Conflicts:
#	x-pack/plugins/screenshotting/server/formats/pdf/index.ts
#	x-pack/plugins/screenshotting/server/screenshots/observable.ts
@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dashboard 302.2KB 304.2KB +2.0KB
unifiedSearch 166.9KB 167.2KB +308.0B
total +2.3KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
maps 70.1KB 70.2KB +90.0B
navigation 9.4KB 9.6KB +147.0B
unifiedSearch 48.5KB 48.6KB +120.0B
total +357.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead release_note:skip Skip the PR/issue when compiling release notes v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants