-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e4eb6d
commit 916f4c8
Showing
5 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...obotshop/app/src/main/java/com/ibm/instashop/common/starttimehandler/LaunchTimeTracker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.ibm.instashop.common.starttimehandler | ||
|
||
import com.instana.android.CustomEvent | ||
import com.instana.android.Instana | ||
|
||
|
||
object LaunchTimeTracker{ | ||
|
||
private var initialTimeInNanos: Long = 0 | ||
var launchTimeInNanos: Long = 0 | ||
private var doneTracking = false | ||
fun startTimer(){ | ||
this.initialTimeInNanos = System.nanoTime() | ||
} | ||
|
||
fun stopTimer():Boolean{ | ||
if(doneTracking){ | ||
return false | ||
} | ||
launchTimeInNanos = System.nanoTime() - this.initialTimeInNanos; | ||
Instana.reportEvent(CustomEvent("APP_START_TIMINGS").apply { | ||
meta = mapOf( | ||
"APP_START_LOAD_TIME_DURATION" to (launchTimeInNanos/1_000_000).toString()+"ms", | ||
) | ||
}) | ||
doneTracking = true | ||
return true | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...botshop/app/src/main/java/com/ibm/instashop/common/starttimehandler/StartupInitializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.ibm.instashop.common.starttimehandler | ||
|
||
import android.content.ContentProvider | ||
import android.content.ContentValues | ||
import android.database.Cursor | ||
import android.net.Uri | ||
|
||
class StartupInitializer : ContentProvider() { | ||
override fun onCreate(): Boolean { | ||
LaunchTimeTracker.startTimer() | ||
return true | ||
} | ||
|
||
override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? { | ||
return null | ||
} | ||
|
||
override fun getType(uri: Uri): String? { | ||
return null | ||
} | ||
|
||
override fun insert(uri: Uri, values: ContentValues?): Uri? { | ||
return null | ||
} | ||
|
||
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int { | ||
return 0 | ||
} | ||
|
||
override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?): Int { | ||
return 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters