@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
44import com.bugsnag.android.BreadcrumbType
55import com.bugsnag.android.Bugsnag
66import timber.log.Timber
7+ import kotlin.time.Duration
78import kotlin.time.measureTime
89
910sealed interface TraceType {
@@ -103,6 +104,7 @@ fun <T> timedTrace(
103104 type : TraceType = TraceType .Log ,
104105 metadata : MetadataBuilder .() -> Unit = {},
105106 error : Throwable ? = null,
107+ onComplete : (T , Duration ) -> Unit = { _, _ -> },
106108 block : () -> T
107109): T {
108110 var result: T
@@ -117,7 +119,7 @@ fun <T> timedTrace(
117119 }
118120
119121 trace(message, tag, type, timedMetadata, error)
120-
122+ onComplete(result, time)
121123 return result
122124}
123125
@@ -127,6 +129,7 @@ suspend fun <T> timedTraceSuspend(
127129 type : TraceType = TraceType .Log ,
128130 metadata : MetadataBuilder .() -> Unit = {},
129131 error : Throwable ? = null,
132+ onComplete : (T , Duration ) -> Unit = { _, _ -> },
130133 block : suspend () -> T
131134): T {
132135 var result: T
@@ -141,7 +144,7 @@ suspend fun <T> timedTraceSuspend(
141144 }
142145
143146 trace(message, tag, type, timedMetadata, error)
144-
147+ onComplete(result, time)
145148 return result
146149}
147150
0 commit comments