From acf9a7033c112b040f9c4635b58c78ee286d3509 Mon Sep 17 00:00:00 2001 From: rosariopf Date: Thu, 6 Oct 2022 23:04:12 +0100 Subject: [PATCH 1/2] feat(perf-ktx): add trace(name, block) extension function --- firebase-perf/ktx/api.txt | 1 + .../main/kotlin/com/google/firebase/perf/ktx/Performance.kt | 6 ++++++ 2 files changed, 7 insertions(+) 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 */ From 60859172a9cf53af87a78418722b3318042a837a Mon Sep 17 00:00:00 2001 From: rosariopf Date: Tue, 11 Oct 2022 15:34:03 -0400 Subject: [PATCH 2/2] add trace to CHANGELOG.md --- firebase-perf/CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) 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.