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

Rendering: Adds PDF support behind feature toggle #81811

Merged
merged 12 commits into from
Feb 8, 2024

Conversation

AgnesToulet
Copy link
Contributor

@AgnesToulet AgnesToulet commented Feb 2, 2024

What is this feature?
This PR adds PDF support in the rendering service behind the newPDFRendering feature toggle.
This will be used for the paid reporting feature.

Why do we need this feature?
This will improve the performance and the maintenance of the reporting feature.

Who is this feature for?
Reporting users.

Special notes for your reviewer:
Associated Enterprise PR: https://github.com/grafana/grafana-enterprise/pull/6232
Associated Image Renderer PR: grafana/grafana-image-renderer#487

@AgnesToulet AgnesToulet added area/image-rendering no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels Feb 5, 2024
@AgnesToulet AgnesToulet added this to the 10.4.x milestone Feb 5, 2024
@AgnesToulet AgnesToulet marked this pull request as ready for review February 5, 2024 09:36
@AgnesToulet AgnesToulet requested review from grafanabot and a team as code owners February 5, 2024 09:36
@AgnesToulet AgnesToulet requested review from Clarity-89, eledobleefe, wbrowne and oshirohugo and removed request for a team February 5, 2024 09:36
Copy link
Member

@torkelo torkelo left a comment

Choose a reason for hiding this comment

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

This is looking great, can't see anything to comment on.

Comment on lines -75 to +77
Encoding: queryReader.Get("encoding", ""),
Encoding: encoding,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@torkelo Maybe we should actually remove this as I don't think we are ready for supporting PDFs here (this won't be behind the feature flag, this makes a currently paid feature free, and I think it should have a UI to set PDF options like zoom and orientation).

Copy link
Member

Choose a reason for hiding this comment

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

@AgnesToulet not sure it matters that much, makes the development of this feature so much easier / faster. PDF support in the image renderer will exposed anyway. This just handles the encoding param so that we return the right content type.

and I think it should have a UI to set PDF options like zoom and orientation).

Don't we have that already? (in enterprise)

I think it's fine to expose a param like this that is not documented / work in progress. As long as not exposed in the UI (without feature toggle) or documented as a supported api feature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a different endpoint in Enterprise. Why is it better to support this in this endpoint rather than in the Enterprise one? (available from the Share > PDF modal)

Copy link
Member

Choose a reason for hiding this comment

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

@AgnesToulet what endpoint is that? can it render any url as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's this one: https://github.com/grafana/grafana-enterprise/blob/main/src/pkg/extensions/report/api/api.go#L123
It's not working with any URL but this calls the same function as the reporting feature.

The issue with using this OSS endpoint to test things out is that you may not have the same result as the PDF feature and break things there while fixing things for this endpoint that we don't really want to support.

Copy link
Member

Choose a reason for hiding this comment

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

I am sorry I don't understand what url / api to use to render dashboard pdf using the new d-report route,

It could be useful to expose while developing so you can directly pass different params to image-renderer service without a rebuild.

But if there is a simple simple api in enterprise then I can use that and we can revert this encoding change.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any problem using the current enpoint -- it is new behavior with new parameter (at least setting pdf as encoding was nonsense before)

Honestly, I'm not convinced we nee the feature toggle newPDFRendering -- but that should buy us time to get the capabilities stuff sorted like: https://github.com/grafana/grafana/blob/v10.3.1/pkg/services/rendering/capabilities.go#L26

Copy link
Member

Choose a reason for hiding this comment

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

@AgnesToulet yea, the enterprise feature not being able to capture any URL as a PDF (So many online/OSS services that can do that), it's the report definition, layout and display options, and scheduling and emailing etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@torkelo You can use it like this: http://localhost:3000/api/reports/render/pdfs?orientation=landscape&layout=grid&scaleFactor=2&dashboards=[{"dashboard":{"uid":"foKOhxxVk"}}]. This is less flexible than the /render endpoint but this is what is called when you export a dashboard into PDF in Grafana.

@ryantxu The feature toggle is needed in Enterprise (see associated PR) so it's using this new workflow instead of the new one. We can't release it directly because, as Torkel said, the reporting feature has a lot more options that we don't support yet.

I guess we can keep this for quick testing, but we should not forget to test the actual endpoint at the end.

Also, for simple PDF export, we should also look into doing it in the frontend directly and not call the image renderer as it should not be needed anymore (but this is not our current priority; our current priority is to reach feature parity with the current PDF export feature).

Copy link
Member

@ryantxu ryantxu left a comment

Choose a reason for hiding this comment

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

🚀

@AgnesToulet AgnesToulet merged commit 28e66b4 into main Feb 8, 2024
19 checks passed
@AgnesToulet AgnesToulet deleted the agnestoulet/pdf-refactor branch February 8, 2024 12:09
Ukochka pushed a commit that referenced this pull request Feb 14, 2024
* start pdf refactor

* Update AppChrome.tsx

* Update AppChrome.tsx

* add encoding param to rendering grpc service

* fix plugin mode

* clean up

* fix backend tests

* fix lint errors

* Support pdf encoding in render http api

---------

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
@aangelisc aangelisc modified the milestones: 10.4.x, 10.4.0 Mar 6, 2024
@AgnesToulet AgnesToulet mentioned this pull request May 6, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend area/frontend area/image-rendering no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes type/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants