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

✨ [RUM-252] optimistic worker creation #2377

Merged
merged 5 commits into from
Aug 24, 2023

Conversation

BenoitZugmeyer
Copy link
Member

@BenoitZugmeyer BenoitZugmeyer commented Aug 11, 2023

Motivation

The Deflate Worker initialization is asynchronous: we instantiate the Worker, we send a first
message and wait for a response to make sure the communication works.

The recorder has been designed to wait until this initialization succeeds before actually starting
to record. This has one major benefit for Replay: no has_replay: true flag is set in case the
Worker initialization fails. If it was set, a link leading to an unknown replay would be displayed
in the Datadog App.

Because we want to use the Deflate Worker in other places, this asynchronous behavior is a bit
inconvenient as it forces the SDK initialization to be asynchronous too, for little benefit because
the worker initialization should succeeds in most case and we don't have the Replay constraint.

Changes

  • Make the worker start "optimistic", so the deflate Worker instance is returned synchronously.

  • Make sure the has_replay (and replay stats) is present only if the worker was correctly
    initialized.

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

Copy link
Member Author

BenoitZugmeyer commented Aug 11, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@codecov-commenter
Copy link

codecov-commenter commented Aug 11, 2023

Codecov Report

Merging #2377 (7803e2a) into main (0f82d93) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2377      +/-   ##
==========================================
- Coverage   93.96%   93.95%   -0.01%     
==========================================
  Files         210      210              
  Lines        6242     6237       -5     
  Branches     1387     1386       -1     
==========================================
- Hits         5865     5860       -5     
  Misses        377      377              
Files Changed Coverage Δ
packages/rum/src/boot/recorderApi.ts 89.65% <100.00%> (+0.56%) ⬆️
packages/rum/src/domain/deflate/deflateWorker.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/optimistic-worker-creation branch from 00df35f to 1aa681b Compare August 11, 2023 16:12
@BenoitZugmeyer
Copy link
Member Author

/to-staging

@dd-devflow
Copy link
Contributor

dd-devflow bot commented Aug 11, 2023

🚂 Branch Integration: starting soon, merge in < 8m

commit 1aa681b58b will soon be integrated into staging-32.

This build is going to start soon! (estimated merge in less than 8m)

you can cancel this operation by commenting your pull request with /to-staging -c!

@dd-devflow
Copy link
Contributor

dd-devflow bot commented Aug 11, 2023

🚂 Branch Integration: this commit was successfully integrated

Commit 1aa681b58b has been merged into staging-32 in merge commit 1b59f70efd.

Check out the triggered pipeline on Gitlab 🦊

@BenoitZugmeyer BenoitZugmeyer marked this pull request as ready for review August 17, 2023 16:00
@BenoitZugmeyer BenoitZugmeyer requested review from a team as code owners August 17, 2023 16:00
createDeflateWorkerImpl = createDeflateWorker
) {
if (state.status === DeflateWorkerStatus.Nil) {
doStartDeflateWorker(configuration, createDeflateWorkerImpl)
Copy link
Contributor

Choose a reason for hiding this comment

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

💭 Maybe add a comment that doStartDeflateWorker can change state.status? I was wondering why it had been taken out of the else statement.

Base automatically changed from benoit/deflate-writer to main August 22, 2023 15:19
@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/optimistic-worker-creation branch from 67977f2 to 2801b02 Compare August 22, 2023 15:34
@BenoitZugmeyer BenoitZugmeyer merged commit 084db3d into main Aug 24, 2023
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/optimistic-worker-creation branch August 24, 2023 08:32
BenoitZugmeyer added a commit that referenced this pull request Aug 24, 2023
* ✨ [RUM-252] optimistic worker creation

* [RUM-252] only set has_replay if the worker is initialized

* 👌 improve test titles and add a comment

* 👌 add recorderApi.getReplayStats tests

Also rename `getReplayStats` to `getReplayStatsImpl` to be less
confusing with the method name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants