Skip to content

RUMM-2775 Add Session Replay Uploader#1063

Merged
mariusc83 merged 3 commits into
feature/session-replay-vofrom
mconstantin/rumm-2275/session-replay-uploader
Oct 3, 2022
Merged

RUMM-2775 Add Session Replay Uploader#1063
mariusc83 merged 3 commits into
feature/session-replay-vofrom
mconstantin/rumm-2275/session-replay-uploader

Conversation

@mariusc83

Copy link
Copy Markdown
Member

What does this PR do?

In this PR we are adding the logic for reading the Session Replay batches, group them into Segments by RUM context and send them as separated payloads.

Note for reviewers: We are using an intermediary hack for now to use the new SDK V2 RequestFactory -> SessionReplayOkHttpUploader. This class and the logic inside will be eventually migrated in the SessionReplayRequestFactory once the batch to multiple requests feature will be available in SDK v2.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@mariusc83 mariusc83 self-assigned this Sep 28, 2022
@mariusc83
mariusc83 marked this pull request as ready for review September 28, 2022 13:16
@mariusc83
mariusc83 requested a review from a team as a code owner September 28, 2022 13:16
@xgouchet xgouchet added the size-large This PR is large sized label Sep 28, 2022
Comment thread dd-sdk-android/build.gradle.kts Outdated
return if (body == null || originalRequest.header(HEADER_ENCODING) != null) {
return if (body == null ||
originalRequest.header(HEADER_ENCODING) != null ||
body is MultipartBody

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we skip Gzip compression, because body is already Gzipped in this case? shouldn't we then add a header (encoding?) saying that it is gzipped? because generally speaking MultipartBody (not from SR) can be in plain as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah I was actually thinking to this but then I will have to change a bit more this logic to go through all the multipart bodies. Let me see if I can do something about it.

internal class BatchesToSegmentsMapper {

fun map(batchData: List<ByteArray>): List<Pair<MobileSegment, JsonObject>> {
return groupBatchDataIntoSegments(batchData)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minor: probably can just inline groupBatchDataIntoSegments here. This method does nothing else than calling another method.

BytesCompressor.CHECKSUM_FLAG_SIZE_IN_BYTES
)
)
decompressor.finished()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we need this call? per documentation it seems it doesn't modify anything, just returns the state.

@codecov-commenter

codecov-commenter commented Sep 29, 2022

Copy link
Copy Markdown

Codecov Report

Merging #1063 (294ab95) into feature/session-replay-vo (e840667) will decrease coverage by 1.01%.
The diff coverage is 44.07%.

@@                      Coverage Diff                      @@
##           feature/session-replay-vo    #1063      +/-   ##
=============================================================
- Coverage                      83.36%   82.35%   -1.01%     
=============================================================
  Files                            343      346       +3     
  Lines                          10791    11042     +251     
  Branches                        1792     1814      +22     
=============================================================
+ Hits                            8995     9093      +98     
- Misses                          1239     1385     +146     
- Partials                         557      564       +7     
Impacted Files Coverage Δ
...replay/internal/net/SessionReplayOkHttpUploader.kt 5.97% <5.97%> (ø)
...lay/internal/domain/SessionReplayRequestFactory.kt 13.33% <13.33%> (-36.67%) ⬇️
...droid/sessionreplay/net/BatchesToSegmentsMapper.kt 85.71% <85.71%> (ø)
...tadog/android/core/internal/net/CurlInterceptor.kt 81.48% <88.89%> (-1.85%) ⬇️
...tadog/android/sessionreplay/net/BytesCompressor.kt 92.86% <92.86%> (ø)
.../android/core/internal/net/DataOkHttpUploaderV2.kt 97.65% <100.00%> (+0.03%) ⬆️
...ndroid/core/internal/net/GzipRequestInterceptor.kt 80.00% <100.00%> (+2.73%) ⬆️
...oid/sessionreplay/internal/SessionReplayFeature.kt 95.00% <100.00%> (+0.41%) ⬆️
.../kotlin/com/datadog/android/v2/core/DatadogCore.kt 67.15% <100.00%> (+0.24%) ⬆️
.../android/sessionreplay/processor/EnrichedRecord.kt 100.00% <100.00%> (ø)
... and 8 more

@xgouchet
xgouchet self-requested a review October 3, 2022 08:26
@mariusc83
mariusc83 force-pushed the mconstantin/rumm-2275/session-replay-uploader branch 2 times, most recently from 7b3ed5b to 294ab95 Compare October 3, 2022 11:06
@mariusc83
mariusc83 requested a review from 0xnm October 3, 2022 11:06

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've added some new comments (plus there are some comments from the previous round), but overall seems good! Just few final edits are needed.

Comment thread detekt.yml Outdated
Comment thread detekt.yml Outdated
Comment thread detekt.yml Outdated
Comment thread detekt.yml Outdated
Comment on lines +17 to +20
/** Maps a batch to a List<Pair<MobileSegment, SerializedMobileSegment>> for uploading.
* This class is meant for internal usage.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A bit of formatting

Suggested change
/** Maps a batch to a List<Pair<MobileSegment, SerializedMobileSegment>> for uploading.
* This class is meant for internal usage.
*/
/**
* Maps a batch to a List<Pair<MobileSegment, SerializedMobileSegment>> for uploading.
* This class is meant for internal usage.
*/

Comment on lines +12 to +15
/** Compresses the payload data using the ZIP compression algorithm.
* This class is meant for internal usage.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/** Compresses the payload data using the ZIP compression algorithm.
* This class is meant for internal usage.
*/
/**
* Compresses the payload data using the ZIP compression algorithm.
* This class is meant for internal usage.
*/

@mariusc83
mariusc83 force-pushed the mconstantin/rumm-2275/session-replay-uploader branch from 294ab95 to 477ff88 Compare October 3, 2022 13:58
@mariusc83
mariusc83 force-pushed the mconstantin/rumm-2275/session-replay-uploader branch from 477ff88 to e0418fe Compare October 3, 2022 14:08

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

@mariusc83
mariusc83 merged commit 05b33e3 into feature/session-replay-vo Oct 3, 2022
@mariusc83
mariusc83 deleted the mconstantin/rumm-2275/session-replay-uploader branch October 3, 2022 14:30
@xgouchet xgouchet added this to the internal milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-large This PR is large sized

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants