From e9a2bcf2b2b3fb73a8af99c0e38ddca9c5525427 Mon Sep 17 00:00:00 2001 From: "Xavier F. Gouchet" Date: Mon, 11 Dec 2023 17:35:17 +0100 Subject: [PATCH] RUM-2441 Print RUM app, session and view ID in LogCat --- .../rum/internal/domain/scope/RumApplicationScope.kt | 2 ++ .../android/rum/internal/domain/scope/RumScope.kt | 4 ++++ .../android/rum/internal/domain/scope/RumSessionScope.kt | 4 ++++ .../android/rum/internal/domain/scope/RumViewScope.kt | 9 ++++++++- local_ci.sh | 1 - 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumApplicationScope.kt b/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumApplicationScope.kt index daf4b76a32..9d0e112094 100644 --- a/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumApplicationScope.kt +++ b/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumApplicationScope.kt @@ -7,6 +7,7 @@ package com.datadog.android.rum.internal.domain.scope import android.app.ActivityManager +import android.util.Log import androidx.annotation.WorkerThread import com.datadog.android.api.InternalLogger import com.datadog.android.api.feature.Feature @@ -77,6 +78,7 @@ internal class RumApplicationScope( syntheticsTestId = event.testId, syntheticsResultId = event.resultId ) + Log.i(RumScope.SYNTHETICS_LOGCAT_TAG, "_dd.application.id=${rumContext.applicationId}") } val isInteraction = (event is RumRawEvent.StartView) || (event is RumRawEvent.StartAction) diff --git a/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumScope.kt b/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumScope.kt index 836ebdf758..fceef344a8 100644 --- a/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumScope.kt +++ b/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumScope.kt @@ -36,4 +36,8 @@ internal interface RumScope { * @return the context related to this scope */ fun getRumContext(): RumContext + + companion object { + internal const val SYNTHETICS_LOGCAT_TAG = "DatadogSynthetics" + } } diff --git a/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumSessionScope.kt b/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumSessionScope.kt index 3829468356..7343f2fc72 100644 --- a/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumSessionScope.kt +++ b/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumSessionScope.kt @@ -6,6 +6,7 @@ package com.datadog.android.rum.internal.domain.scope +import android.util.Log import androidx.annotation.WorkerThread import com.datadog.android.api.feature.Feature import com.datadog.android.api.storage.DataWriter @@ -200,6 +201,9 @@ internal class RumSessionScope( sessionId = UUID.randomUUID().toString() sessionStartNs.set(nanoTime) sessionListener?.onSessionStarted(sessionId, !keepSession) + if (getRumContext().syntheticsTestId != null) { + Log.i(RumScope.SYNTHETICS_LOGCAT_TAG, "_dd.session.id=$sessionId") + } } private fun updateSessionStateForSessionReplay(state: State, sessionId: String) { diff --git a/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScope.kt b/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScope.kt index dbec5c8c52..ec1819c085 100644 --- a/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScope.kt +++ b/features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScope.kt @@ -6,6 +6,7 @@ package com.datadog.android.rum.internal.domain.scope +import android.util.Log import androidx.annotation.WorkerThread import com.datadog.android.api.InternalLogger import com.datadog.android.api.feature.Feature @@ -67,6 +68,9 @@ internal open class RumViewScope( set(value) { oldViewIds += field field = value + if (getRumContext().syntheticsTestId!=null) { + Log.i(RumScope.SYNTHETICS_LOGCAT_TAG, "_dd.view.id=$viewId") + } } private val oldViewIds = mutableSetOf() private val startedNanos: Long = eventTime.nanoTime @@ -141,6 +145,9 @@ internal open class RumViewScope( cpuVitalMonitor.register(cpuVitalListener) memoryVitalMonitor.register(memoryVitalListener) frameRateVitalMonitor.register(frameRateVitalListener) + if (parentScope.getRumContext().syntheticsTestId != null) { + Log.i(RumScope.SYNTHETICS_LOGCAT_TAG, "_dd.view.id=$viewId") + } } // region RumScope @@ -1167,7 +1174,7 @@ internal open class RumViewScope( * * As we take the inverse, the min of the inverse is the inverse of the max and * vice-versa. - * For instance, if the the min frame time is 20ms (50 fps) and the max is 500ms (2 fps), + * For instance, if the min frame time is 20ms (50 fps) and the max is 500ms (2 fps), * the max frame rate is 50 fps (1/minValue) and the min is 2 fps (1/maxValue). * * As the frame times are reported in nanoseconds, we need to add a multiplier. diff --git a/local_ci.sh b/local_ci.sh index 1d21880cd1..1e52695ea8 100755 --- a/local_ci.sh +++ b/local_ci.sh @@ -124,7 +124,6 @@ if [[ $ANALYSIS == 1 ]]; then echo "------ Detekt public API rules" detekt --config "$DD_SOURCE/domains/mobile/config/android/gitlab/detekt/detekt-public-api.yml" - if [[ $COMPILE == 1 ]]; then # Assemble is required to get generated classes type resolution echo "------ Assemble Libraries"