From b3140d2f5775ba0ce00884b5eb5d57ff20baa760 Mon Sep 17 00:00:00 2001 From: jobykorahgeorge Date: Fri, 2 Aug 2024 13:05:44 +0530 Subject: [PATCH] StartTime Capture with updated logics --- .../app/src/main/AndroidManifest.xml | 11 ++++++----- .../common/starttimehandler/LaunchTimeTracker.kt | 10 +++++++--- .../app/src/main/java/com/ibm/instashop/di/App.kt | 5 +++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/android-compose-robotshop/app/src/main/AndroidManifest.xml b/android-compose-robotshop/app/src/main/AndroidManifest.xml index eb0a5ae..0925483 100644 --- a/android-compose-robotshop/app/src/main/AndroidManifest.xml +++ b/android-compose-robotshop/app/src/main/AndroidManifest.xml @@ -15,6 +15,11 @@ android:supportsRtl="true" android:theme="@style/Theme.RobotShop" tools:targetApi="31"> + - + \ No newline at end of file diff --git a/android-compose-robotshop/app/src/main/java/com/ibm/instashop/common/starttimehandler/LaunchTimeTracker.kt b/android-compose-robotshop/app/src/main/java/com/ibm/instashop/common/starttimehandler/LaunchTimeTracker.kt index e23e56d..d62df7d 100644 --- a/android-compose-robotshop/app/src/main/java/com/ibm/instashop/common/starttimehandler/LaunchTimeTracker.kt +++ b/android-compose-robotshop/app/src/main/java/com/ibm/instashop/common/starttimehandler/LaunchTimeTracker.kt @@ -1,5 +1,7 @@ package com.ibm.instashop.common.starttimehandler +import android.os.SystemClock +import android.util.Log import com.instana.android.CustomEvent import com.instana.android.Instana @@ -10,19 +12,21 @@ object LaunchTimeTracker{ var launchTimeInNanos: Long = 0 private var doneTracking = false fun startTimer(){ - this.initialTimeInNanos = System.nanoTime() + this.initialTimeInNanos = SystemClock.elapsedRealtime() } fun stopTimer():Boolean{ if(doneTracking){ return false } - launchTimeInNanos = System.nanoTime() - this.initialTimeInNanos; + launchTimeInNanos = SystemClock.elapsedRealtime() - this.initialTimeInNanos; Instana.reportEvent(CustomEvent("APP_START_TIMINGS").apply { + duration = launchTimeInNanos meta = mapOf( - "APP_START_LOAD_TIME_DURATION" to (launchTimeInNanos/1_000_000).toString()+"ms", + "APP_START_LOAD_TIME_DURATION" to (launchTimeInNanos).toString()+"ms", ) }) + Log.i("Displayed com",(launchTimeInNanos).toString()+"ms") doneTracking = true return true } diff --git a/android-compose-robotshop/app/src/main/java/com/ibm/instashop/di/App.kt b/android-compose-robotshop/app/src/main/java/com/ibm/instashop/di/App.kt index 5698661..7cdda70 100644 --- a/android-compose-robotshop/app/src/main/java/com/ibm/instashop/di/App.kt +++ b/android-compose-robotshop/app/src/main/java/com/ibm/instashop/di/App.kt @@ -20,9 +20,10 @@ class App : Application(){ lateinit var dataManager: DataManager override fun onCreate() { super.onCreate() - if(dataManager.getString(INSTANA_KEY).isNotEmpty()&&dataManager.getString(INSTANA_URL).isNotEmpty()){ + Thread.sleep(300) + if(dataManager.getString(INSTANA_KEY).isNotEmpty()&&dataManager.getString(INSTANA_URL).isNotEmpty()){ setupInstana(dataManager.getString(INSTANA_KEY),dataManager.getString(INSTANA_URL)) - } + } if(dataManager.getString(Constants.CURRENT_API_VERSION).isNotEmpty()){ CurrentVersionInUse = dataManager.getString(Constants.CURRENT_API_VERSION) }