Skip to content

Commit 10c7f1f

Browse files
authored
Merge pull request #2621 from DataDog/nogorodnikov/rum-9720/remove-force-new-batch-api
RUM-9720: Remove `forceNewBatch` API
2 parents 1480798 + b4d9bbc commit 10c7f1f

File tree

43 files changed

+164
-358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+164
-358
lines changed

dd-sdk-android-core/api/apiSurface

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ interface com.datadog.android.api.feature.FeatureEventReceiver
108108
fun onReceive(Any)
109109
interface com.datadog.android.api.feature.FeatureScope
110110
val dataStore: com.datadog.android.api.storage.datastore.DataStoreHandler
111-
fun withWriteContext(Boolean = false, (com.datadog.android.api.context.DatadogContext, com.datadog.android.api.storage.EventBatchWriter) -> Unit)
111+
fun withWriteContext((com.datadog.android.api.context.DatadogContext, com.datadog.android.api.storage.EventBatchWriter) -> Unit)
112112
fun sendEvent(Any)
113113
fun <T: Feature> unwrap(): T
114114
fun <R: Any?> com.datadog.android.api.InternalLogger.measureMethodCallPerf(Class<*>, String, Float = 100f, () -> R): R

dd-sdk-android-core/api/dd-sdk-android-core.api

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,7 @@ public abstract interface class com/datadog/android/api/feature/FeatureScope {
344344
public abstract fun getDataStore ()Lcom/datadog/android/api/storage/datastore/DataStoreHandler;
345345
public abstract fun sendEvent (Ljava/lang/Object;)V
346346
public abstract fun unwrap ()Lcom/datadog/android/api/feature/Feature;
347-
public abstract fun withWriteContext (ZLkotlin/jvm/functions/Function2;)V
348-
}
349-
350-
public final class com/datadog/android/api/feature/FeatureScope$DefaultImpls {
351-
public static synthetic fun withWriteContext$default (Lcom/datadog/android/api/feature/FeatureScope;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V
347+
public abstract fun withWriteContext (Lkotlin/jvm/functions/Function2;)V
352348
}
353349

354350
public final class com/datadog/android/api/feature/FeatureScopeExtKt {

dd-sdk-android-core/src/main/kotlin/com/datadog/android/api/feature/FeatureScope.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@ interface FeatureScope {
2323

2424
/**
2525
* Utility to write an event, asynchronously.
26-
* @param forceNewBatch if `true` forces the [EventBatchWriter] to write in a new file and
27-
* not reuse the already existing pending data persistence file. By default it is `false`.
2826
* @param callback an operation called with an up-to-date [DatadogContext]
2927
* and an [EventBatchWriter]. Callback will be executed on a worker thread from I/O pool.
3028
* [DatadogContext] will have a state created at the moment this method is called, before the
3129
* thread switch for the callback invocation.
3230
*/
3331
@AnyThread
3432
fun withWriteContext(
35-
forceNewBatch: Boolean = false,
3633
callback: (DatadogContext, EventBatchWriter) -> Unit
3734
)
3835

dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/SdkFeature.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ internal class SdkFeature(
169169
// region FeatureScope
170170

171171
override fun withWriteContext(
172-
forceNewBatch: Boolean,
173172
callback: (DatadogContext, EventBatchWriter) -> Unit
174173
) {
175174
// TODO RUM-1462 thread safety. Thread switch happens in Storage right now. Open questions:
@@ -179,7 +178,7 @@ internal class SdkFeature(
179178
val contextProvider = coreFeature.contextProvider
180179
if (contextProvider is NoOpContextProvider) return
181180
val context = contextProvider.context
182-
storage.writeCurrentBatch(context, forceNewBatch) { callback(context, it) }
181+
storage.writeCurrentBatch(context) { callback(context, it) }
183182
}
184183

185184
override fun sendEvent(event: Any) {

dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/metrics/BatchClosedMetadata.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ package com.datadog.android.core.internal.metrics
88

99
internal data class BatchClosedMetadata(
1010
internal val lastTimeWasUsedInMs: Long,
11-
internal val forcedNew: Boolean,
1211
internal val eventsCount: Long
1312
)

dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/metrics/BatchMetricsDispatcher.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ internal class BatchMetricsDispatcher(
136136
// be sent as a batch_delete telemetry later
137137
BATCH_SIZE_KEY to file.lengthSafe(internalLogger),
138138
BATCH_EVENTS_COUNT_KEY to batchMetadata.eventsCount,
139-
FORCE_NEW_KEY to batchMetadata.forcedNew,
140139
TRACKING_CONSENT_KEY to file.resolveFileOriginAsConsent(),
141140
FILE_NAME to file.name,
142141
THREAD_NAME to Thread.currentThread().name
@@ -246,9 +245,6 @@ internal class BatchMetricsDispatcher(
246245
/* The duration from batch creation to batch closing (in ms).*/
247246
internal const val BATCH_DURATION_KEY = "batch_duration"
248247

249-
/* If the batch was closed by core or after new batch was forced by the feature.*/
250-
internal const val FORCE_NEW_KEY = "forced_new"
251-
252248
internal const val BATCH_CLOSED_MESSAGE = "[Mobile Metric] Batch Closed"
253249

254250
/* The value for the type of the metric.*/

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ internal class AbstractStorage(
6161
@AnyThread
6262
override fun writeCurrentBatch(
6363
datadogContext: DatadogContext,
64-
forceNewBatch: Boolean,
6564
callback: (EventBatchWriter) -> Unit
6665
) {
6766
executorService.executeSafe("Data write", internalLogger) {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ internal class ConsentAwareStorage(
5555
@WorkerThread
5656
override fun writeCurrentBatch(
5757
datadogContext: DatadogContext,
58-
forceNewBatch: Boolean,
5958
callback: (EventBatchWriter) -> Unit
6059
) {
6160
executorService.executeSafe("Data write", internalLogger) {
@@ -68,7 +67,6 @@ internal class ConsentAwareStorage(
6867
synchronized(writeLock) {
6968
val writer = FileEventBatchWriter(
7069
fileOrchestrator = orchestrator,
71-
forceNewBatch = forceNewBatch,
7270
eventsWriter = batchEventsReaderWriter,
7371
metadataReaderWriter = batchMetadataReaderWriter,
7472
filePersistenceConfig = filePersistenceConfig,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import java.util.Locale
2121

2222
internal class FileEventBatchWriter(
2323
private val fileOrchestrator: FileOrchestrator,
24-
private val forceNewBatch: Boolean,
2524
private val eventsWriter: FileWriter<RawBatchEvent>,
2625
private val metadataReaderWriter: FileReaderWriter,
2726
private val filePersistenceConfig: FilePersistenceConfig,
@@ -32,7 +31,7 @@ internal class FileEventBatchWriter(
3231
@get:WorkerThread
3332
private val batchFile: File? by lazy {
3433
@Suppress("ThreadSafety") // called in the worker context
35-
fileOrchestrator.getWritableFile(forceNewFile = forceNewBatch)
34+
fileOrchestrator.getWritableFile()
3635
}
3736

3837
@get:WorkerThread

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@ internal interface Storage {
2222
/**
2323
* Utility to write data, asynchronously.
2424
* @param datadogContext the context for the write operation
25-
* @param forceNewBatch if `true` will force the writer to start a new batch before storing the
26-
* data. By default this flag is `false`.
2725
* @param callback an operation to perform with a [EventBatchWriter] that will target the current
2826
* writeable Batch
2927
*/
3028
@AnyThread
3129
fun writeCurrentBatch(
3230
datadogContext: DatadogContext,
33-
forceNewBatch: Boolean,
3431
callback: (EventBatchWriter) -> Unit
3532
)
3633

0 commit comments

Comments
 (0)