Skip to content

RUM-16305: Update several hardcoded data limits#3616

Open
aleksandr-gringauz wants to merge 2 commits into
developfrom
aleksandr-gringauz/RUM-16305/fix-limits
Open

RUM-16305: Update several hardcoded data limits#3616
aleksandr-gringauz wants to merge 2 commits into
developfrom
aleksandr-gringauz/RUM-16305/fix-limits

Conversation

@aleksandr-gringauz

@aleksandr-gringauz aleksandr-gringauz commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Aligns several hardcoded client-side data limits with the documented backend limits. Mirrors the equivalent iOS change in dd-sdk-ios#2832.

Changes

Change Doc
Max batch / payload size 4 MB → 5 MB. Logs API — Send logs
Max items per batch 500 → 1000. Logs API — Send logs
Max item / single-event size 512 KB → 1 MB. Logs API — Send logs

Motivation

@aleksandr-gringauz aleksandr-gringauz force-pushed the aleksandr-gringauz/RUM-16305/fix-limits branch 3 times, most recently from 4481575 to 252d193 Compare July 9, 2026 13:30
@codecov-commenter

codecov-commenter commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.29%. Comparing base (70c67a3) to head (214860f).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3616      +/-   ##
===========================================
+ Coverage    73.27%   73.29%   +0.01%     
===========================================
  Files          995      995              
  Lines        36258    36258              
  Branches      6125     6125              
===========================================
+ Hits         26568    26572       +4     
- Misses        7979     7986       +7     
+ Partials      1711     1700      -11     
Files with missing lines Coverage Δ
...android/api/storage/FeatureStorageConfiguration.kt 100.00% <100.00%> (ø)
...internal/persistence/file/FilePersistenceConfig.kt 100.00% <ø> (ø)

... and 41 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aleksandr-gringauz aleksandr-gringauz force-pushed the aleksandr-gringauz/RUM-16305/fix-limits branch from 252d193 to 214860f Compare July 15, 2026 12:25
@aleksandr-gringauz aleksandr-gringauz marked this pull request as ready for review July 15, 2026 12:45
@aleksandr-gringauz aleksandr-gringauz requested review from a team as code owners July 15, 2026 12:45
hamorillo
hamorillo previously approved these changes Jul 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 214860fb54

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

maxItemSize = 1024L * 1024,
maxItemsPerBatch = 1000,
// 5 MB
maxBatchSize = 5L * 1024 * 1024,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Leave headroom before appending the last event

With this default set to the full 5 MB intake limit, a batch can grow past that limit before upload: SdkFeature copies this value into FilePersistenceConfig, and BatchFileOrchestrator only checks lastFile.lengthSafe(...) < config.maxBatchSize before FileEventBatchWriter appends another event that is now allowed to be up to 1 MB. When a file is just under 5 MB, the next valid event can therefore produce a request over 5 MB (plus request separators/prefixes), and the uploader treats a 413 as a non-retryable client error, so that batch is dropped. Please keep headroom here or change the write path to check current size plus the next event before appending.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a valid point actually...

maxBatchSize = 4L * 1024 * 1024,
// 1 MB
maxItemSize = 1024L * 1024,
maxItemsPerBatch = 1000,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep Session Replay batches capped at 500 items

This default is also inherited by FeatureStorageConfiguration.DEFAULT.copy(...) callers that don't override maxItemsPerBatch. The Session Replay, SR resources, and WebView replay storage configs still document a 500-item batch cap while only overriding item and byte sizes, so small replay/resource payloads can now be grouped into 1000-item uploads instead of the intended 500. Please override maxItemsPerBatch = 500 in those custom configs (or update them deliberately) rather than changing the global default out from under them.

Useful? React with 👍 / 👎.

internal const val MAX_ITEM_SIZE: Long = 1024L * 1024 // 1 MB
internal const val OLD_FILE_THRESHOLD: Long = 18L * 60L * 60L * 1000L // 18 hours
internal const val MAX_DISK_SPACE: Long = 128 * MAX_BATCH_SIZE // 512 MB
internal const val MAX_DISK_SPACE: Long = 128 * MAX_BATCH_SIZE // 640 MB

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the disk budget independent of batch size

Because BatchFileOrchestrator.freeSpaceIfNeeded() purges only after config.maxDiskSpace, deriving this from the new 5 MB batch size raises each storage directory's cap from the documented 512 MB to 640 MB. On apps with multiple storage-backed features and both pending/granted directories, this lets the SDK retain substantially more data on device even though the PR is only aligning intake payload limits; please keep the disk cap fixed unless the storage budget is intentionally being changed and documented.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8523c51219

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


val isRecentEnough = isFileRecent(lastFile, recentWriteDelayMs)
val hasRoomForMore = lastFile.lengthSafe(internalLogger) < config.maxBatchSize
val hasRoomForMore = lastFile.lengthSafe(internalLogger) < config.maxBatchSize - config.maxItemSize

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reserve request framing bytes before appending

For logs/RUM/traces batches that are just under maxBatchSize - maxItemSize, this still reuses the file and accepts another event up to maxItemSize, but the uploaded body is not only the raw event bytes: LogsRequestFactory adds [/,/] framing and RUM/traces join events with separators. That leaves zero bytes for request framing, so a max-size final event can still produce a 413, which DataUploadRunnable drops as a non-retryable client error; please keep additional overhead headroom or check the actual serialized body size before reusing the batch.

Useful? React with 👍 / 👎.


val isRecentEnough = isFileRecent(lastFile, recentWriteDelayMs)
val hasRoomForMore = lastFile.lengthSafe(internalLogger) < config.maxBatchSize
val hasRoomForMore = lastFile.lengthSafe(internalLogger) < config.maxBatchSize - config.maxItemSize

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid forcing 10 MB features into single-item batches

For Session Replay, SR resources, and WebView replay, the storage configs set maxItemSize equal to maxBatchSize (10 MB), so this new threshold becomes lastFile.lengthSafe(...) < 0 for every existing batch. After the first small replay record/resource is written, the next write can never reuse that batch, effectively turning the documented 1000-item cap into one upload per item and losing SR segment/resource batching; please base the decision on the actual next event size or special-case equal item/batch limits.

Useful? React with 👍 / 👎.

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.

3 participants