-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Unified observability] Fix refresh button in the overview page #126927
[Unified observability] Fix refresh button in the overview page #126927
Conversation
Pinging @elastic/unified-observability (Team:Unified observability) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some manual testing and I found a couple of things:
-
When navigating to the overview page, the timerange is not added to the URL, it's only added when the user interacts with the timepicker. In other apps (tried APM and uptime) it is added when the user navigates to it. Should we do the same?
It could be a problem when someone wants to save the URL or share it, and they come from a different app where they modified the timerange.
If it's too much to do in this PR, it should be fine if we open a follow-up issue. -
When the timerange selected is
today
,this week
or start and end are absolute, the Refresh button doesn't work:
Screen.Recording.2022-03-08.at.15.26.17.mov
I think it's because the timerange doesn't change, but we should do the request again as there could be more data (the only request done is from the alerts table).
I can use a
Mmmm, good catch. I guess in those the resolved absolute values don't change. I can expose the Let me address both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality works well.
There's a bit of inconsistency of when the range appears or when it doesn't in the url on overview page. When link is clicked, there's no range (though it does appear momentarily). But when page is refreshed, it is there in the url. Is it intentional? It is different than how it was behaving before the PR changes.
Before
Screen.Recording.2022-03-09.at.14.35.24.mov
After
Screen.Recording.2022-03-09.at.14.38.20.mov
@awahab07 it is intentional to show the range in the URL on page load, but it shouldn't flicker like you describe. I cannot reproduce this behaviour on Firefox, Safari or Chrome. Maybe it was a hiccup of your local install caused when switching branches? |
@afgomez yes, it could be due to switching branches. I'll rebuild everything and test again. |
@afgomez I've checked after a fresh build, I still see the same issue (on refresh, url contains time range). I am connecting my local Kibana to a remote edge cluster, probably that's the difference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (except for some failing tests at the time of reviewing)
- Time range values are correctly preserved across Observability Overview Page and plugins (I focused only on Uptime and User Experience plugins).
- Absolute and relative time values are correctly passed in requests.
- Refresh button works well on Uptime and UX plugin.
- Sharing url correctly populates the time range.
const absoluteStart = useMemo( | ||
() => getAbsoluteTime(relativeStart), | ||
// `lastUpdated` works as a cache buster | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[relativeStart, lastUpdated] | ||
); | ||
|
||
const absoluteEnd = useMemo( | ||
() => getAbsoluteTime(relativeEnd, { roundUp: true }), | ||
// `lastUpdated` works as a cache buster | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[relativeEnd, lastUpdated] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's always better to not cache derived values, if possible.
The absolute*
values are consumed outside of useFetcher
as well, see
const min = moment.utc(absoluteStart).valueOf();
const max = moment.utc(absoluteEnd).valueOf();
So it's a question of whether getAbsoluteTime
is more expensive than moment.utc
. If it is, then caching is serving a purpose here. One advantage of leaving them cached in context is that if there were future use cases where plugins consume absolute time values, they won't have to re-calculate.
Pinging @elastic/uptime (Team:uptime) |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
⚪ Backport skippedThe pull request was not backported as there were no branches to backport to. If this is a mistake, please apply the desired version labels or run the backport tool manually. Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
…tic#126927) Co-authored-by: Kibana Machine <[email protected]>
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Summary
Fixes the refresh button in the overview page.
The state for the time range for the overview page was handled in the URL. The only value present there was the relative range (
now-15m...now
and similar).The different panels were reading from this value to determine if they had to re-render or not. The refresh button updated these values in the URL... but they stayed the same because they were relative values.
What we want instead is to use the absolute values of the range (the resolved values for
now-15m
andnow
). However the current solution had two issues:useTimeRange
wasn't shared.This PR addresses this two issues by creating a new context for the time ranges. This caches the absolute values so they don't update on each re-render and reliably determines when they need to be updated. It also functions as a source of truth for the range state instead of leveraging the URL.
I took the opportunity to also handle here the refresh information for the datepicker.