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-253] compress RUM data #2400

Merged
merged 12 commits into from
Oct 31, 2023
Merged

Conversation

BenoitZugmeyer
Copy link
Member

@BenoitZugmeyer BenoitZugmeyer commented Aug 30, 2023

Motivation

To reduce the bandwidth impact when using the RUM Browser SDK, we want to compress data sent to the
backend.

Changes

This PR implement data compression for the "rum" package/bundle behind an experimental feature flag.
This will stay like this during dogfooding, then we'll introduce a proper initialization parameter +
support it on "rum-slim" and "logs" as well.

Testing


I have gone over the contributing documentation.

@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/compress--rum-data branch from 51ca845 to 1cd7901 Compare September 5, 2023 10:26
@BenoitZugmeyer BenoitZugmeyer changed the base branch from main to benoit/compress--adapt-transport September 5, 2023 10:45
@BenoitZugmeyer
Copy link
Member Author

BenoitZugmeyer commented Sep 5, 2023

@BenoitZugmeyer BenoitZugmeyer changed the title ⚗️✨ compress RUM data ⚗️✨ [RUM-235] compress RUM data Sep 5, 2023
@BenoitZugmeyer BenoitZugmeyer marked this pull request as ready for review September 5, 2023 10:49
@BenoitZugmeyer BenoitZugmeyer requested review from a team as code owners September 5, 2023 10:49
@BenoitZugmeyer BenoitZugmeyer changed the title ⚗️✨ [RUM-235] compress RUM data ⚗️✨ [RUM-253] compress RUM data Sep 5, 2023
return new Batch(
createHttpRequest(configuration, endpointBuilder, configuration.batchBytesLimit, reportError),
encoder || createIdentityEncoder(),
Copy link
Contributor

Choose a reason for hiding this comment

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

💭 thought: ‏I had a hard time understanding in which case the encoder was undefined and I'm wondering if it could me simplified. FMU we have to look at:

Personally I prefer to have a rumPublicApi as dump as possible and make the instantiation checks in startRum.
Also, It could be nice to create the encoder in startRum() to remove the logic from startRumBatch and startBatchWithReplica.
I don't know all the intricacies of the implement so it might no be feasible 🙂 Let me know what you think.

Copy link
Member Author

Choose a reason for hiding this comment

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

As seen IRL, I changed a bit how encoders are created so the condition on whether we use an "Identity" or "Deflate" encoder is clearer.

@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/compress--rum-data branch 3 times, most recently from 7a494ca to de29ea4 Compare September 8, 2023 16:46
@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2023

Codecov Report

Attention: Patch coverage is 97.77778% with 4 lines in your changes missing coverage. Please review.

Project coverage is 93.86%. Comparing base (5d5935c) to head (e4853e1).
Report is 412 commits behind head on main.

Current head e4853e1 differs from pull request most recent head ebb9a24

Please upload reports for the commit ebb9a24 to get more accurate results.

Files with missing lines Patch % Lines
packages/rum/src/domain/deflate/deflateEncoder.ts 95.12% 2 Missing ⚠️
packages/core/src/transport/batch.ts 97.22% 1 Missing ⚠️
packages/core/src/transport/httpRequest.ts 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2400      +/-   ##
==========================================
+ Coverage   93.26%   93.86%   +0.60%     
==========================================
  Files         221      222       +1     
  Lines        6580     6459     -121     
  Branches     1443     1431      -12     
==========================================
- Hits         6137     6063      -74     
+ Misses        443      396      -47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/compress--rum-data branch from 8329f48 to 399820b Compare September 8, 2023 17:12
@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/compress--adapt-transport branch from ec86af6 to 5466106 Compare September 11, 2023 14:12
@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/compress--rum-data branch from 399820b to 3a7384d Compare September 11, 2023 14:12
@@ -29,19 +29,21 @@ export function createDeflateEncoder(
configuration,
worker,
'message',
({ data: workerResponse }: MessageEvent<DeflateWorkerResponse>) => {
if (workerResponse.type !== 'wrote' || workerResponse.streamId !== streamId) {
({ data }: MessageEvent<DeflateWorkerResponse>) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ question: ‏you have reverted the previous commit changes, is it intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, no, must have been a conflict resolution error.

Base automatically changed from benoit/compress--adapt-transport to main September 15, 2023 13:55
This new interface is slightly different than the current deflate
encoder implementation. This is because it has been adjusted to take the
Batch constraints into account.

The deflate encoder implementation will be changed in a future commit.
This commit is not pretty. To avoid having inflated packages while
dogfooding, we pass some functions from rum to rum-core when creating
the RUM public API.

In the future, those functions will be moved to the core package, and
rum-core will be able to import them directly.
@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/compress--rum-data branch from e4853e1 to ebb9a24 Compare October 30, 2023 13:48
@BenoitZugmeyer BenoitZugmeyer merged commit 0013510 into main Oct 31, 2023
2 checks passed
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/compress--rum-data branch October 31, 2023 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants