diff --git a/firebase-perf/CHANGELOG.md b/firebase-perf/CHANGELOG.md index 97f9f0b2b17..f1da211f000 100644 --- a/firebase-perf/CHANGELOG.md +++ b/firebase-perf/CHANGELOG.md @@ -1,5 +1,15 @@ # Unreleased +* + +## Kotlin +The Kotlin extensions library transitively includes the updated +`firebase-performance` library. The Kotlin extensions library has the following +additional updates: + +* [feature] Added a [`trace(String, Trace.() -> T)`](https://firebase.google.com/docs/reference/kotlin/com/google/firebase/perf/ktx/package-summary#trace(kotlin.String,kotlin.Function1)) + extension function to create a custom trace with the given name. + # 20.2.0 * [unchanged] Updated to accommodate the release of the updated [perfmon] Kotlin extensions library. diff --git a/firebase-perf/ktx/api.txt b/firebase-perf/ktx/api.txt index 0dd6cae8883..2498d874952 100644 --- a/firebase-perf/ktx/api.txt +++ b/firebase-perf/ktx/api.txt @@ -5,6 +5,7 @@ package com.google.firebase.perf.ktx { method @NonNull public static com.google.firebase.perf.FirebasePerformance getPerformance(@NonNull com.google.firebase.ktx.Firebase); method public static inline void trace(@NonNull com.google.firebase.perf.metrics.HttpMetric, @NonNull kotlin.jvm.functions.Function1 block); method public static inline T trace(@NonNull com.google.firebase.perf.metrics.Trace, @NonNull kotlin.jvm.functions.Function1 block); + method public static inline T trace(@NonNull String name, @NonNull kotlin.jvm.functions.Function1 block); } } diff --git a/firebase-perf/ktx/src/main/kotlin/com/google/firebase/perf/ktx/Performance.kt b/firebase-perf/ktx/src/main/kotlin/com/google/firebase/perf/ktx/Performance.kt index 365a6f2afb2..244c2d67226 100644 --- a/firebase-perf/ktx/src/main/kotlin/com/google/firebase/perf/ktx/Performance.kt +++ b/firebase-perf/ktx/src/main/kotlin/com/google/firebase/perf/ktx/Performance.kt @@ -48,6 +48,12 @@ inline fun Trace.trace(block: Trace.() -> T): T { } } +/** + * Creates a [Trace] object with given [name] and measures the time it takes to + * run the [block] wrapped by calls to [start] and [stop]. + */ +inline fun trace(name: String, block: Trace.() -> T): T = Trace.create(name).trace(block) + internal const val LIBRARY_NAME: String = "fire-perf-ktx" /** @suppress */