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

Delay journey finish #140383

Merged
merged 1 commit into from
Sep 9, 2022
Merged

Delay journey finish #140383

merged 1 commit into from
Sep 9, 2022

Conversation

suchcodemuchwow
Copy link
Contributor

This PR aims to add delay to journeys which are closing before ongoing requests to telemetry clusters finishes.

Note: We are not sure if browser buffers the event requests to server, if that is the case we have to check if buffer cleaned up. Looking for more information how analytics client sending these requests, @afharo can provide more context around that.

Fixes: #140253

@suchcodemuchwow suchcodemuchwow added Team:Operations Team label for Operations Team release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting v8.5.0 labels Sep 9, 2022
@suchcodemuchwow suchcodemuchwow requested review from spalger, afharo and a team September 9, 2022 11:31
@suchcodemuchwow suchcodemuchwow self-assigned this Sep 9, 2022
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

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

cc @suchcodemuchwow

@suchcodemuchwow suchcodemuchwow marked this pull request as ready for review September 9, 2022 14:00
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@suchcodemuchwow suchcodemuchwow merged commit 4408507 into elastic:main Sep 9, 2022
@afharo
Copy link
Member

afharo commented Sep 12, 2022

Apologies for the delay in my response, just confirming that the browser side does buffer all the events for 1 second:

// Buffer events for 1 second or until we have an optIn value
bufferWhen(() => interval(1000).pipe(skipWhile(() => this.isOptedIn$.value === undefined))),

There is a tear-down logic that should attempt to send all pending events. This is called in the stop lifecycle step. However, currently, core does not trigger the stop lifecycle step when closing the browser (#132696).

@spalger
Copy link
Contributor

spalger commented Sep 12, 2022

@afharo any chance we could get a global method we could call to flush the buffer, that returns a promise which resolves when the items in the buffer have been sent? It's probably not critical, but if we could call such a method from playwright then we could be very confident all telemetry produced during the test was sent without needing to worry about non-deterministic timers.

@afharo
Copy link
Member

afharo commented Sep 12, 2022

I'm not familiar with playwright and the scope it runs (which methods it can see and call). But happy to explore the option. We could also expose an emitter from the client or log something whenever we are done shipping all the events in the queue.

Can you create an issue so we can discuss our options?

@spalger
Copy link
Contributor

spalger commented Sep 12, 2022

Issue: #140521

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 Team:Operations Team label for Operations Team v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Journeys close too early and events don't get sent
5 participants