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

feat(DiffView): Add CTAs and comparison presets #231

Merged
merged 58 commits into from
Oct 30, 2024
Merged

Conversation

grafakus
Copy link
Contributor

@grafakus grafakus commented Oct 21, 2024

✨ Description

Related issue(s): resolves #224

This PR adds two call to actions when the user lands on the view:

  • "Auto-select": will select half of each time ranges for the diff flame graph
  • "Choose a preset": will open the presets dropdown
Before After
image image

Additionally, it introduces the new Comparison presets dropdown to help our users to quickly select different time periods:

image

Currently, we only provide 6 built-in presets:

  1. Last hour (30m-window)
  2. Last hour (1h-window)
  3. 6h ago vs now (30m-window)
  4. 24h ago vs now (30m-window)
  5. Auto-select (half range)
  6. Auto-select (whole range)

📖 Summary of the changes

See diff tab.

🧪 How to test?

  • The build should pass
  • Manually, after checking out this PR

@github-actions github-actions bot added the feat label Oct 21, 2024
Copy link
Contributor

github-actions bot commented Oct 21, 2024

Unit test coverage

Lines Statements Branches Functions
Coverage: 11%
11.6% (447/3851) 9.05% (123/1358) 8.49% (104/1224)

@grafakus grafakus changed the base branch from main to feat/consistent-header October 21, 2024 12:08
@grafakus grafakus changed the title feat(DiffFlameGraph): Add presets feat(DiffFlameGraph): Add CTAs when landing on the page Oct 25, 2024
@grafakus grafakus changed the title feat(DiffFlameGraph): Add CTAs when landing on the page feat(DiffFlameGraph): Add CTAs when the user lands on the page Oct 25, 2024
@grafakus grafakus changed the title feat(DiffFlameGraph): Add CTAs when the user lands on the page feat(DiffFlameGraph): Add CTAs when the user lands on the view Oct 25, 2024
@grafakus grafakus self-assigned this Oct 28, 2024
@grafakus grafakus marked this pull request as ready for review October 28, 2024 12:57
@grafakus grafakus changed the title feat(DiffFlameGraph): Add CTAs when the user lands on the view feat(DiffFlameGraph): Add CTAs and comparison presets Oct 28, 2024
@grafakus grafakus changed the title feat(DiffFlameGraph): Add CTAs and comparison presets feat(DiffView): Add CTAs and comparison presets Oct 28, 2024
@grafakus grafakus requested a review from ifrost October 29, 2024 08:46
@ifrost
Copy link
Contributor

ifrost commented Oct 29, 2024

Related issue(s): relates to #224

Does it only relate or actually fixes that issues? Is there anything else to do?

Copy link
Contributor

@ifrost ifrost left a comment

Choose a reason for hiding this comment

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

Looks good 🙌 works as expected. One thing that is missing is one event is not being tracked. Other comments are non-blocking 👍

}
});

return {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (non-blocking): Automatically clean up subscriptions

I think in scenes when you use this._subs.add(...) it will automatically clean up all subscriptions when a scene is deactivated. Anything added with this.subscribeToEvent(...) should also be removed automatically:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for this! I always wanted to refactor it ; I'll do it in a future PR.

}

setDiffRange(diffFrom: string, diffTo: string) {
const $diffTimeRange = this.state.timeseriesPanel.state.body.state.$timeRange as SceneTimeRangeWithAnnotations;
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: Should pull the state up?

Drilling down the state looks a bit cumbersome and makes testing harder do to mocking. Do you think it would make sense / be feasible to pull timeRange state up and save it only in SceneComparePanel. Timeseries panel looks for nearest timeRange anyway so will use the same one. This is not needed in this PR, just food for thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we discussed face to face: this time range is actually a timerange-like object (a hack) that we use to enable annotations on the time series (see SceneTimeRangeWithAnnotations). So it makes sense that we keep it as close as possible as where it's used (it's also responsible to change the data received from the API on-the-fly, in order to add the annotation on the time series).

Also, if in the future the platform provides a way to add range selections out-of-the-box (via a new API or so), it's likely that it's going to be configured on the timeseries panel.

Finally, for testing, I wouldn't mock anything ; I'd use end-to-end testing as we do now because these user interactions are quite complex (because they involve many different components).

@grafakus grafakus requested review from ifrost October 30, 2024 17:29
@grafakus
Copy link
Contributor Author

@ifrost I'll merge this one and work on the follow-ups tomorrow. Thank you for the review and comments!

@grafakus grafakus merged commit e8bbf2e into main Oct 30, 2024
4 of 5 checks passed
@grafakus grafakus deleted the feat/diff-presets branch October 30, 2024 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[diff flame graph view] Clarify what the user has to do to see the diff flame graph
2 participants