Skip to content

Commit 8523c51

Browse files
RUM-16305: PR fixes
1 parent 214860f commit 8523c51

6 files changed

Lines changed: 36 additions & 5 deletions

File tree

dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/persistence/file/FilePersistenceConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal data class FilePersistenceConfig(
2323
internal const val MAX_ITEMS_PER_BATCH: Int = 1000
2424
internal const val MAX_ITEM_SIZE: Long = 1024L * 1024 // 1 MB
2525
internal const val OLD_FILE_THRESHOLD: Long = 18L * 60L * 60L * 1000L // 18 hours
26-
internal const val MAX_DISK_SPACE: Long = 128 * MAX_BATCH_SIZE // 640 MB
26+
internal const val MAX_DISK_SPACE: Long = 512L * 1024 * 1024 // 512 MB
2727
internal const val MAX_DELAY_BETWEEN_MESSAGES_MS = 5000L
2828
internal const val CLEANUP_FREQUENCY_THRESHOLD_MS = 5000L // 5s
2929
}

dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/persistence/file/batch/BatchFileOrchestrator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ internal class BatchFileOrchestrator(
237237
}
238238

239239
val isRecentEnough = isFileRecent(lastFile, recentWriteDelayMs)
240-
val hasRoomForMore = lastFile.lengthSafe(internalLogger) < config.maxBatchSize
240+
val hasRoomForMore = lastFile.lengthSafe(internalLogger) < config.maxBatchSize - config.maxItemSize
241241
val hasSlotForMore = (lastKnownFileItemCount < config.maxItemsPerBatch)
242242

243243
return if (isRecentEnough && hasRoomForMore && hasSlotForMore) {

dd-sdk-android-core/src/test/kotlin/com/datadog/android/core/internal/persistence/file/batch/BatchFileOrchestratorTest.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,37 @@ internal class BatchFileOrchestratorTest {
522522
verifyNoMoreInteractions(mockMetricsDispatcher)
523523
}
524524

525+
@Test
526+
fun `M return new File W getWritableFile() {previous file leaves no room for a max-size item}`(
527+
@StringForgery(size = MAX_BATCH_SIZE - MAX_ITEM_SIZE) previousData: String
528+
) {
529+
// Given
530+
assumeTrue(fakeRootDir.listFiles().isNullOrEmpty())
531+
val fileCreateTimestamp = stubTimeProvider.deviceTimestampMs
532+
val previousFile = testedOrchestrator.getWritableFile()
533+
checkNotNull(previousFile)
534+
previousFile.writeText(previousData)
535+
stubTimeProvider.deviceTimestampMs += 1
536+
val newFileTimestamp = stubTimeProvider.deviceTimestampMs
537+
538+
// When
539+
val result = testedOrchestrator.getWritableFile()
540+
541+
// Then
542+
checkNotNull(result)
543+
assertThat(result)
544+
.doesNotExist()
545+
.hasParent(fakeRootDir)
546+
assertThat(result.name.toLong()).isEqualTo(newFileTimestamp)
547+
assertThat(previousFile.readText()).isEqualTo(previousData)
548+
argumentCaptor<BatchClosedMetadata> {
549+
verify(mockMetricsDispatcher).sendBatchClosedMetric(eq(previousFile), capture())
550+
assertThat(firstValue.lastTimeWasUsedInMs).isEqualTo(fileCreateTimestamp)
551+
assertThat(firstValue.eventsCount).isEqualTo(1L)
552+
}
553+
verifyNoMoreInteractions(mockMetricsDispatcher)
554+
}
555+
525556
@Test
526557
fun `M return new File W getWritableFile() {previous file has too many items}`(
527558
forge: Forge

features/dd-sdk-android-session-replay/src/main/kotlin/com/datadog/android/sessionreplay/internal/ResourcesFeature.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ internal class ResourcesFeature(
5858
/**
5959
* Session Replay Resources storage configuration with the following parameters:
6060
* max item size = 10 MB,
61-
* max items per batch = 500,
61+
* max items per batch = 1000,
6262
* max batch size = 10 MB, SR intake batch limit is 10MB
6363
* old batch threshold = 18 hours.
6464
*/

features/dd-sdk-android-session-replay/src/main/kotlin/com/datadog/android/sessionreplay/internal/SessionReplayFeature.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ internal class SessionReplayFeature(
402402
/**
403403
* Session Replay storage configuration with the following parameters:
404404
* max item size = 10 MB,
405-
* max items per batch = 500,
405+
* max items per batch = 1000,
406406
* max batch size = 10 MB, SR intake batch limit is 10MB
407407
* old batch threshold = 5 hours.
408408
*/

features/dd-sdk-android-webview/src/main/kotlin/com/datadog/android/webview/internal/replay/WebViewReplayFeature.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ internal class WebViewReplayFeature(
5959
/**
6060
* Storage configuration with the following parameters:
6161
* max item size = 10 MB,
62-
* max items per batch = 500,
62+
* max items per batch = 1000,
6363
* max batch size = 10 MB, SR intake batch limit is 10MB
6464
* old batch threshold = 18 hours.
6565
*/

0 commit comments

Comments
 (0)