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] Track retryAt and startedAt times on the task instance #174409

Merged

Conversation

tsullivan
Copy link
Member

@tsullivan tsullivan commented Jan 6, 2024

Summary

Initial part of #131852

This PR moves towards auto-calculating the maximum timeouts calculated based on the timing context provided by the running task instance.

Other changes

  • Added an optional logger parameter to the getScreenshots function. When a logger is provided, the logs created by the screenshot plugin will have the contextual tags added by the calling code.

    • Before
      image
    • After
      image
  • Fixed an unreported bug where browser timezone was not utilized in PNG reports.

Checklist

Delete any items that are not applicable to this PR.

@tsullivan tsullivan force-pushed the reporting-taskinstance-retryat-tracking branch 2 times, most recently from 22c1bfc to 742e20f Compare January 10, 2024 17:07
@tsullivan
Copy link
Member Author

/ci

@tsullivan tsullivan force-pushed the reporting-taskinstance-retryat-tracking branch 3 times, most recently from ab82ea1 to ce7307f Compare January 10, 2024 20:06
@tsullivan tsullivan force-pushed the reporting-taskinstance-retryat-tracking branch from ce7307f to 5773365 Compare January 10, 2024 20:47
@tsullivan tsullivan force-pushed the reporting-taskinstance-retryat-tracking branch from 5773365 to 9c5ec58 Compare January 10, 2024 21:47
@@ -122,9 +119,12 @@ export class PngExportType extends ExportType<JobParamsPNGV2, TaskPayloadPNGV2>
return this.startDeps
.screenshotting!.getScreenshots({
format: 'png',
browserTimezone: payload.browserTimezone,
Copy link
Member Author

Choose a reason for hiding this comment

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

Oops! browserTimezone was not being passed before. That could have caused PNG reports showing date values formatted in the timezone of the Kibana server rather than the end user client. It doesn't seem to be a previosly known issue.

@tsullivan tsullivan marked this pull request as ready for review January 10, 2024 22:41
@tsullivan tsullivan requested review from a team as code owners January 10, 2024 22:41
@tsullivan tsullivan added the release_note:skip Skip the PR/issue when compiling release notes label Jan 10, 2024
@elastic elastic deleted a comment from kibana-ci Jan 10, 2024
@elastic elastic deleted a comment from kibana-ci Jan 11, 2024
@tsullivan tsullivan added the backport:skip This commit does not require backporting label Jan 11, 2024
@@ -38,6 +43,7 @@ export type CreateJobFn<JobParamsType = BaseParams, JobPayloadType = BasePayload
export type RunTaskFn<TaskPayloadType = BasePayload> = (
jobId: string,
payload: TaskPayloadType,
taskInstanceFields: TaskInstanceFields,
Copy link
Member Author

Choose a reason for hiding this comment

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

To make the task lifecycle timing information available to the run task functions, I just added this new parameter to for all Run Task functions.

@@ -108,9 +108,11 @@ export class CsvSearchSourceImmediateExportType extends ExportType<
};
const cancellationToken = new CancellationToken();
const csvConfig = this.config.csv;
const taskInstanceFields = { startedAt: null, retryAt: null };
Copy link
Member Author

Choose a reason for hiding this comment

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

Here is another example of why the "immediate" CSV export type doesn't fit well into the reporting framework: getting the export available to download immediately doesn't go through Task Manager.

Related: #164104

Copy link
Contributor

@eokoneyo eokoneyo 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 left couple of questions that's mostly nits

@@ -430,7 +431,7 @@ export class ExecuteReportTask implements ReportingTask {
eventLog.logExecutionStart();

const output = await Promise.race<TaskRunResult>([
this._performJob(task, cancellationToken, stream),
this._performJob(task, taskInstance, cancellationToken, stream),
Copy link
Contributor

Choose a reason for hiding this comment

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

should we pass just the properties we defined for the TaskInstanceFields type instead of the whole taskInstanceField object received from the task manager?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! a4b5189

Comment on lines 33 to 50
/**
* Timestamp metrics about a running screenshot task
* which determine the maximum timeouts possible
*/
export interface TaskInstanceFields {
/**
* The date and time that this task started execution. This is used to determine
* the "real" runAt that ended up running the task. This value is only set
* when status is set to "running".
*/
startedAt: Date | null;

/**
* The date and time that this task should re-execute if stuck in "running" / timeout
* status. This value is only set when status is set to "running".
*/
retryAt: Date | null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think we can create the same type definition we have here https://github.com/elastic/kibana/pull/174409/files#diff-f4342d4c59ca76e69910849e6c0b35157d2c4cb0da0d7bc91fd632720ab2c0e0 that selects from ConcreteTaskInstance

Copy link
Member Author

@tsullivan tsullivan Jan 16, 2024

Choose a reason for hiding this comment

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

👍🏻 b377d00 4ac9663

@tsullivan tsullivan enabled auto-merge (squash) January 16, 2024 20:21
@tsullivan tsullivan changed the title [Reporting] Track retryAt time on the task instance [Reporting] Track retryAt and startedAt times on the task instance Jan 16, 2024
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/generate-csv 10 11 +1
@kbn/reporting-export-types-csv 50 52 +2
@kbn/reporting-export-types-pdf 31 33 +2
@kbn/reporting-export-types-png 15 16 +1
@kbn/reporting-server 77 79 +2
total +8

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/reporting-common 7 8 +1
Unknown metric groups

API count

id before after diff
@kbn/generate-csv 10 11 +1
@kbn/reporting-export-types-csv 50 52 +2
@kbn/reporting-export-types-pdf 32 34 +2
@kbn/reporting-export-types-png 16 17 +1
@kbn/reporting-server 78 80 +2
total +8

History

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

@tsullivan tsullivan merged commit decec37 into elastic:main Jan 16, 2024
19 checks passed
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
## Summary

Initial part of elastic#131852

This PR moves towards auto-calculating the maximum timeouts calculated
based on the timing context provided by the running task instance.

### Other changes
* Added an optional logger parameter to the `getScreenshots` function.
When a logger is provided, the logs created by the screenshot plugin
will have the contextual tags added by the calling code.
  * Before
<img width="1198" alt="image"
src="https://github.com/elastic/kibana/assets/908371/f68a102e-6af2-4863-aedb-52f1e4a099d8">
  * After
<img width="1200" alt="image"
src="https://github.com/elastic/kibana/assets/908371/2dd4c947-ffa6-4cb3-b8a2-22893f49ddb7">

* Fixed an unreported bug where browser timezone was not utilized in PNG
reports.

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
@tsullivan tsullivan deleted the reporting-taskinstance-retryat-tracking branch April 30, 2024 21:43
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 release_note:skip Skip the PR/issue when compiling release notes v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants