-
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
[Expressions] Update expressions public API to expose partial results support #102403
Conversation
jenkins, test this (restarting due to jenkins upgrade) |
7e79486
to
2bc22d4
Compare
Pinging @elastic/kibana-app-services (Team:AppServices) |
this.data$.subscribe((data) => { | ||
this.render(data); | ||
this.data$.subscribe(({ result }) => { | ||
this.render(result); |
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.
loader needs to receive an option if partial results should be rendered or not,
if option is false (default), we only render when partial===false
@@ -30,7 +30,11 @@ export interface ReactExpressionRendererProps extends IExpressionLoaderParams { | |||
) => React.ReactElement | React.ReactElement[]; | |||
padding?: 'xs' | 's' | 'm' | 'l' | 'xl'; | |||
onEvent?: (event: ExpressionRendererEvent) => void; | |||
onData$?: <TData, TInspectorAdapters>(data: TData, adapters?: TInspectorAdapters) => void; | |||
onData$?: <TData, TInspectorAdapters>( |
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.
we need a prop to allow opting in to partial result. we should pass that to loader then, if prop is not enabled partial data should not be rendered (only final results)
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 might be missing something but this looks like it's not possible to disable partial rendering when using the expression renderer component? As we want to provide indication for partial results in the rendered Lens chart, we need a way to selectively disable partial results.
Edit: What Peter said (#102403 (comment))
@ppisljar @flash1293 I have added an option to disable partial results in the loader and the renderer. Could you please take another look? |
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'm reviewing this and seeing that I have two assumptions that are not fully met here:
-
Lens might conditionally render partial results, for example if there is a time series vs terms aggregation.
-
Lens might implement some kind of progress indicator as a percentage, like 50% loaded.
/** | ||
* Partial result flag. | ||
*/ | ||
partial: boolean; |
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.
We need more than just a flag for partial data, we need some kind of status indicator as well. Typically I'd imagine this is the shard responses: 100 total shards, 5 successful, 50 skipped, 1 failure.
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.
We cannot predict that because an expression function can emit an indefinite number of results. So the best you can do is to implement the progress indication in a function.
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.
So the best you can do is to implement the progress indication in a function
Can you elaborate on how this would look like? I think this is an important part of supporting partial results.
I can imagine this information being part of the datatable (what do you think @ppisljar ?) but I think we need to find some kind of solution for it.
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.
@dokmic Elasticsearch indicates the number of successful vs total shards on every partial status call, this is what I'm referring to: async search status
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.
@flash1293 @wylieconlon this PR does not try to address progress indication apart from letting the consumer know when result is partial vs final. Progress reporting will be added at a later time, right now its not even supported on our low level search service.
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.
@ppisljar Right, I understand that it's not supported yet. What I'm asking is that we implement an API that can support a progress indicator, not just a boolean.
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.
we didn't want to do anything more for now as we don't know yet in what form progress from es will be provided to us or how we'd want to report this on expression level. in the future we are likely to keep this partial flag and add another progress variable.
|
||
subscriber.add( | ||
source.subscribe({ | ||
next: (result) => { |
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 seems like sources need to provide their own partial status indicator here, not just automatically setting it to partial: true
.
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.
That's being overwritten later on the same frame upon completion. So for the last result that will be true
. You can also see that in the unit test.
Maybe I'm missing something, but this should be possible with the changes on this PR, right? adds the |
@elasticmachine merge upstream |
@flash1293 I think you're right that this PR does expose options for us. We can always set |
I'm not sure whether this is fully working for Lens (at least for the other bucket). I set the Line 643 in b35cde5
but the Line 456 in b35cde5
As far as I understood the other bucket should be treated as partial result, right? |
@flash1293 That does not work because the |
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
@dokmic The piece of code you linked is not used in the Lens editor, it's only used on dashboards. I retried on the latest version and it doesn't work for me, I guess I'm doing something wrong. These are the steps I took:
If you are seeing something else I'm happy to sync offline to clear up my confusion. |
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.
Discussed this offline and this PR won't give the ability the actually render partial results in Lens yet - further steps are necessary (esaggs
has to return an observable instead of a promise).
I tested Lens, Visualize and TSVB and didn't notice anything breaking. LGTM for Kibana app side.
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.
Okay, LGTM. I agree that we can add an additional parameter to indicate the status of the partial results.
@flash1293 Other bucket is not the only way to test the partial results, but it does seem like an easy one. The other one that I've found to work pretty well is creating a script that performs more work on older data and less work on newer data. Sharing this script in case it helps:
ZonedDateTime date = doc['@timestamp'].value;
long doctime = date.toInstant().toEpochMilli();
String datetime = '2021-07-07T22:15:30Z';
ZonedDateTime now = ZonedDateTime.parse(datetime);
long nowtime = now.toInstant().toEpochMilli();
long multiple = 20 * (nowtime - doctime) / 31536000000L;
for (int i = 0; i < multiple; i++) {
String local = '1983-10-13T22:15:30Z';
ZonedDateTime localz = ZonedDateTime.parse(datetime);
long epoch = localz.toInstant().toEpochMilli();
}
emit(multiple);
The other change that needs to be made to test locally is updating batched_reduce_size: 64
-> batched_reduce_size: 2
in request_utils.ts
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
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
Summary
Updates expressions plugin to expose partial results support.
Resolves #98280.
Checklist
For maintainers