Skip to content

Commit 255ddc2

Browse files
committed
RUM-9908 update RUM Scope interface
1 parent 67598c9 commit 255ddc2

File tree

7 files changed

+18
-6
lines changed

7 files changed

+18
-6
lines changed

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumActionScope.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit
2424
import kotlin.math.max
2525

2626
internal class RumActionScope(
27-
val parentScope: RumScope,
27+
override val parentScope: RumScope,
2828
private val sdkCore: InternalSdkCore,
2929
val waitForStop: Boolean,
3030
eventTime: Time,

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumApplicationScope.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ internal class RumApplicationScope(
4242
private val slowFramesListener: SlowFramesListener?
4343
) : RumScope, RumViewChangedListener {
4444

45+
override val parentScope: RumScope? = null
46+
4547
private var rumContext = RumContext(applicationId = applicationId)
4648

4749
internal val childScopes: MutableList<RumScope> = mutableListOf(

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumResourceScope.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import java.util.UUID
3535

3636
@Suppress("LongParameterList", "TooManyFunctions")
3737
internal class RumResourceScope(
38-
internal val parentScope: RumScope,
38+
override val parentScope: RumScope,
3939
internal val sdkCore: InternalSdkCore,
4040
internal val url: String,
4141
internal val method: RumResourceMethod,

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumScope.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ package com.datadog.android.rum.internal.domain.scope
99
import androidx.annotation.WorkerThread
1010
import com.datadog.android.api.storage.DataWriter
1111
import com.datadog.android.rum.internal.domain.RumContext
12-
import com.datadog.tools.annotation.NoOpImplementation
1312

1413
@NoOpImplementation
1514
internal interface RumScope {
1615

16+
val parentScope: RumScope?
17+
1718
/**
1819
* Handles an incoming event.
1920
* If needed, writes a RumEvent to the provided writer.
@@ -37,6 +38,15 @@ internal interface RumScope {
3738
*/
3839
fun getRumContext(): RumContext
3940

41+
/**
42+
* @return the custom attributes for this scope (including the parent's scope current attributes)
43+
* A given scope's attribute can override a parent scope's attribute.
44+
*/
45+
fun getCustomAttributes(): Map<String, Any?> {
46+
// Default implementation, simply returns the parent's attributes
47+
return parentScope?.getCustomAttributes() ?: emptyMap()
48+
}
49+
4050
companion object {
4151
internal const val SYNTHETICS_LOGCAT_TAG = "DatadogSynthetics"
4252
}

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumSessionScope.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import java.util.concurrent.atomic.AtomicLong
2727

2828
@Suppress("LongParameterList")
2929
internal class RumSessionScope(
30-
private val parentScope: RumScope,
30+
override val parentScope: RumScope,
3131
private val sdkCore: InternalSdkCore,
3232
private val sessionEndedMetricDispatcher: SessionMetricDispatcher,
3333
internal val sampleRate: Float,

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewManagerScope.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit
3333

3434
@Suppress("LongParameterList")
3535
internal class RumViewManagerScope(
36-
private val parentScope: RumScope,
36+
override val parentScope: RumScope,
3737
private val sdkCore: InternalSdkCore,
3838
private val sessionEndedMetricDispatcher: SessionMetricDispatcher,
3939
private val backgroundTrackingEnabled: Boolean,

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScope.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import kotlin.math.min
5454

5555
@Suppress("TooManyFunctions", "LargeClass", "LongParameterList")
5656
internal open class RumViewScope(
57-
private val parentScope: RumScope,
57+
override val parentScope: RumScope,
5858
private val sdkCore: InternalSdkCore,
5959
private val sessionEndedMetricDispatcher: SessionMetricDispatcher,
6060
internal val key: RumScopeKey,

0 commit comments

Comments
 (0)