Skip to content

Commit

Permalink
StartTime Capture with updated logics
Browse files Browse the repository at this point in the history
  • Loading branch information
jobykorahgeorgeibm committed Aug 2, 2024
1 parent 916f4c8 commit b3140d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
11 changes: 6 additions & 5 deletions android-compose-robotshop/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
android:supportsRtl="true"
android:theme="@style/Theme.RobotShop"
tools:targetApi="31">
<provider
android:name=".common.starttimehandler.StartupInitializer"
android:authorities="${applicationId}.appstartprovider"
android:initOrder="500"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true"
Expand All @@ -26,11 +31,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name=".common.starttimehandler.StartupInitializer"
android:authorities="${applicationId}.instanaagentinitializer"
android:initOrder="2147483647"
android:exported="false" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit b3140d2

Please sign in to comment.