-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Logs UI] Add default refresh interfal on streaming #151711
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
[Logs UI] Add default refresh interfal on streaming #151711
Conversation
|
Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI) |
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.
Thanks for looking at this 🙏
The live streaming mode of the Logs UI sets the refresh interval back to 5 s when initializing instead of using the time service default of 60 s
Looking at the ACs we can simplify this process, and tie it explicitly to the initialisation phase of the state machine.
I can see a few problems with the use of this setDefaultRefreshInterval action:
-
The
setDefaultRefreshIntervalaction will overwrite any value supplied in the URL. This is a bug. -
Tying a
setDefaultRefreshIntervalaction to theinitializedstate will technically work here as the transitions on the events are internal (e.g.target: '.initialized'- with a relative target - which means theentryactions won't refire). However, if these events were to re-enter theinitializedstate we would potentially overwrite changes the user has made in the UI. -
It's not clear why the
setDefaultRefreshIntervalaction would be tied to theinitializedstate, rather than theinitializingstates. By the time we move to theinitializedstate we want everything to be "ready". -
The action is last in the chain, and we always preserve action order. This means we notify the parent (
notifyTimeChanged) of a value that is different to the context by the timesetDefaultRefreshIntervalis called. This won't lead to bugs now, but could in the future.
The order of precedence for the state is defaults > time filter service > URL but we want to disregard the time filter service for the refresh interval when initializing.
The base level defaults are supplied as initial context here. At this point the interval is correct.
We then want to make sure in the next step in the chain, initialising from the time filter service, we don't overwrite this value with the higher value. This is where the value is sent with it's event.. I would still send across the value as part of the event, so it's complete, but disregard it when the updateTimeContextFromTimeFilterService action alters the context, so keep whether it's paused, but disregard the interval.
Lastly if there's a URL interval set, this has ultimate precedence and will overwrite both.
I think this flow makes more sense, what do you think?
|
@Kerry350 Thank you very much for the good explanation!
Really good point! I understand your concerns and you are right that we don't want to override an URL value if it's not the default one. I can confirm that it happens when you set an interval after starting the stream then stop the stream and refresh the page ( when I tested the same case without stopping the steam it persisted the new value but then it was not overriding the value probably because it was initialized already)
Actually, I wasn't really sure if it was the correct state, I wanted it to be after the default value of 1m is set so we won't reset it back but the order of the actions will make sense in those cases instead of moving into a state where we considered everything "ready" 👍 So if I understand correctly we want to override the value inside the |
ee6d3da to
fad16cc
Compare
…too-long-default-refresh-interval-from-the-time-service
I would say that what we want to do is subtract the value from the
That's right, the Unfortunately the time filter service, regardless of whether one or both values was changed, will send both values. So we probably need to check (on an update, not init) "is the value equal to the default". This led to a lot of issues in the past and I ended up having to add an explicit
I think with the URL we can just leave it's handling as is, because even if we're reading the defaults (but back from the URL) that's fine. I try to think of this as layering the context from left to right for initialisation:
For the URL these values may well just reflect the base defaults (as they'll always be pushed once reaching the initialized state) but that's okay. They are ultimately correct. I think the changes could look somewhat like this (not tested): export const updateTimeContextFromTimeFilterService = actions.assign(
(context: LogStreamQueryContext, event: LogStreamQueryEvent) => {
if (
event.type === 'TIME_FROM_TIME_FILTER_SERVICE_CHANGED' ||
event.type === 'INITIALIZED_FROM_TIME_FILTER_SERVICE'
) {
return {
...getTimeFromEvent(context, event),
refreshInterval:
event.type === 'TIME_FROM_TIME_FILTER_SERVICE_CHANGED'
? event.refreshInterval
: { ...event.refreshInterval, value: DEFAULT_REFRESH_INTERVAL.value },
};
} else {
return {};
}
}
);Alternatively you could have something like: The remaining issue we have is just the "has the user actually touched the interval value, or are we just receiving the default back again". To truly fix that I think we'd need to have the observable of the service communicate that, so that we can do something like |
|
(Just realised you've pushed almost the same change whilst I was writing my comment, sorry 🙈) |
|
For context for others: @jennypavlova and I jumped on a call, and I'm actually an idiot and forgot that, due to the fact we sync our fully initialised values back to the time filter service, we are therefore protected against the issue outlined above. Because we'll just receive our value back essentially, unless the user changes it. This is nice because it actually validates our ordering and syncing. The time issue was a bit different as the order of precedence was actually a bit different and we had a slightly different approach. |
|
@Kerry350 Thank you for checking that with me, I applied the changes we discussed. |
…too-long-default-refresh-interval-from-the-time-service
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
Kerry350
left a comment
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 🙌
Thank you for persevering with my stream of thoughts 🙏
Closes #150626
Summary
This PR sets the default streaming refresh interval to 5 seconds.
Testing
Go to Logs -> Stream

Click on
Stream livebuttonThe refresh interval should be now 5s (not 1m as it was before)