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

[Screenshotting/PDF Worker Thread] send log messages from the worker to the main thread #194493

Closed
tsullivan opened this issue Sep 30, 2024 · 1 comment · Fixed by #196860
Closed
Assignees
Labels
good first issue low hanging fruit papercut Small "burr" in the product that we should fix. Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)

Comments

@tsullivan
Copy link
Member

tsullivan commented Sep 30, 2024

Kibana Screenshotting uses a worker thread to generate a PDF file by embedding a PNG buffer into a PDF template. This worker thread has the function to send buffer data back to the main thread for storage.

Today, the worker thread doesn't create any log messages, because it doesn't have any context from Kibana and doesn't have a reference to any dependencies. This issue creates a situation where it's hard to understand any potential failure, such as the generic "Worker did not generate a PDF" error.

The worker thread should be able to send different types of messages to the parent thread: a type for the buffer data and a type for the log messages. This can be done by adding a type property to the payloads sent from the worker thread.

// Send log message to the main thread
port.postMessage({ type: 'log', message: 'Worker started generating buffer data' });

// Send the buffer data back to the main thread
port.postMessage({ type: 'data', response: successResponse }, [buffer.buffer /* transfer ownership of the data to the main thread instead of copying it */]);

// Keep sending status logs
port.postMessage({ type: 'log', message: 'Worker completed' });
@tsullivan tsullivan added the Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) label Sep 30, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@petrklapka petrklapka added the good first issue low hanging fruit label Oct 7, 2024
@tsullivan tsullivan changed the title [Screenshotting/PDF Worker Thread] Find a way to send log messages from the worker to the main thread [Screenshotting/PDF Worker Thread] send log messages from the worker to the main thread Oct 10, 2024
@petrklapka petrklapka added the papercut Small "burr" in the product that we should fix. label Oct 17, 2024
@kowalczyk-krzysztof kowalczyk-krzysztof self-assigned this Oct 18, 2024
kowalczyk-krzysztof added a commit that referenced this issue Oct 21, 2024
…196860)

## Summary

This PR adds a `type` to `GeneratePdfResponse` and introduces more
logging for PDF worker.

Closes: #194493
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Oct 21, 2024
…lastic#196860)

## Summary

This PR adds a `type` to `GeneratePdfResponse` and introduces more
logging for PDF worker.

Closes: elastic#194493
(cherry picked from commit c25a97b)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Oct 21, 2024
…lastic#196860)

## Summary

This PR adds a `type` to `GeneratePdfResponse` and introduces more
logging for PDF worker.

Closes: elastic#194493
(cherry picked from commit c25a97b)
kibanamachine added a commit that referenced this issue Oct 21, 2024
…onse (#196860) (#197128)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Screenshotting/PDF Worker Thread] Add type to GeneratePdfResponse
(#196860)](#196860)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Krzysztof
Kowalczyk","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-21T19:15:58Z","message":"[Screenshotting/PDF
Worker Thread] Add type to GeneratePdfResponse (#196860)\n\n##
Summary\r\n\r\nThis PR adds a `type` to `GeneratePdfResponse` and
introduces more\r\nlogging for PDF worker.\r\n\r\nCloses:
#194493","sha":"c25a97bc0a3a85ad5c7bb18aab7916410efd05b7","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:SharedUX","v8.16.0","Feature:Reporting:Screenshot","backport:version","v8.17.0"],"title":"[Screenshotting/PDF
Worker Thread] Add type to
GeneratePdfResponse","number":196860,"url":"https://github.com/elastic/kibana/pull/196860","mergeCommit":{"message":"[Screenshotting/PDF
Worker Thread] Add type to GeneratePdfResponse (#196860)\n\n##
Summary\r\n\r\nThis PR adds a `type` to `GeneratePdfResponse` and
introduces more\r\nlogging for PDF worker.\r\n\r\nCloses:
#194493","sha":"c25a97bc0a3a85ad5c7bb18aab7916410efd05b7"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196860","number":196860,"mergeCommit":{"message":"[Screenshotting/PDF
Worker Thread] Add type to GeneratePdfResponse (#196860)\n\n##
Summary\r\n\r\nThis PR adds a `type` to `GeneratePdfResponse` and
introduces more\r\nlogging for PDF worker.\r\n\r\nCloses:
#194493","sha":"c25a97bc0a3a85ad5c7bb18aab7916410efd05b7"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Krzysztof Kowalczyk <[email protected]>
kibanamachine added a commit that referenced this issue Oct 21, 2024
…nse (#196860) (#197129)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Screenshotting/PDF Worker Thread] Add type to GeneratePdfResponse
(#196860)](#196860)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Krzysztof
Kowalczyk","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-21T19:15:58Z","message":"[Screenshotting/PDF
Worker Thread] Add type to GeneratePdfResponse (#196860)\n\n##
Summary\r\n\r\nThis PR adds a `type` to `GeneratePdfResponse` and
introduces more\r\nlogging for PDF worker.\r\n\r\nCloses:
#194493","sha":"c25a97bc0a3a85ad5c7bb18aab7916410efd05b7","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:SharedUX","v8.16.0","Feature:Reporting:Screenshot","backport:version","v8.17.0"],"title":"[Screenshotting/PDF
Worker Thread] Add type to
GeneratePdfResponse","number":196860,"url":"https://github.com/elastic/kibana/pull/196860","mergeCommit":{"message":"[Screenshotting/PDF
Worker Thread] Add type to GeneratePdfResponse (#196860)\n\n##
Summary\r\n\r\nThis PR adds a `type` to `GeneratePdfResponse` and
introduces more\r\nlogging for PDF worker.\r\n\r\nCloses:
#194493","sha":"c25a97bc0a3a85ad5c7bb18aab7916410efd05b7"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196860","number":196860,"mergeCommit":{"message":"[Screenshotting/PDF
Worker Thread] Add type to GeneratePdfResponse (#196860)\n\n##
Summary\r\n\r\nThis PR adds a `type` to `GeneratePdfResponse` and
introduces more\r\nlogging for PDF worker.\r\n\r\nCloses:
#194493","sha":"c25a97bc0a3a85ad5c7bb18aab7916410efd05b7"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Krzysztof Kowalczyk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue low hanging fruit papercut Small "burr" in the product that we should fix. Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants