Skip to content

Commit 69392b7

Browse files
committed
Deprecate all SafeTrace/SafeTraceFunctions APIs
1 parent 71e3b87 commit 69392b7

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

papa-safetrace/src/main/java/papa/SafeTrace.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ object SafeTrace {
5959
/**
6060
* @see isShellProfileable
6161
*/
62+
@Deprecated("Call forceEnableAppTracing/enableMainThreadMessageTracing instead")
6263
@JvmStatic
6364
fun forceShellProfileable() {
6465
androidx.tracing.Trace.forceEnableAppTracing()
@@ -93,6 +94,7 @@ object SafeTrace {
9394
* Writes a trace message to indicate that a given section of code has begun. This call must
9495
* be followed by a corresponding call to {@link #endSection()} on the same thread.
9596
*/
97+
@Deprecated("Call androidx.tracing.Trace.beginSection instead", ReplaceWith("beginSection", "androidx.tracing.Trace.beginSection"))
9698
@JvmStatic
9799
fun beginSection(label: String) {
98100
if (!isCurrentlyTracing) {
@@ -101,6 +103,7 @@ object SafeTrace {
101103
androidx.tracing.Trace.beginSection(label.take(MAX_LABEL_LENGTH))
102104
}
103105

106+
@Deprecated("Call androidx.tracing.Trace.beginSection instead", ReplaceWith("beginSection", "androidx.tracing.Trace.beginSection"))
104107
@JvmStatic
105108
inline fun beginSection(crossinline labelLambda: () -> String) {
106109
if (!isCurrentlyTracing) {
@@ -113,6 +116,7 @@ object SafeTrace {
113116
* Begins and ends a section immediately. Useful for reporting information in the trace.
114117
*/
115118
@JvmStatic
119+
@Deprecated("Call androidx.tracing.Trace.beginSection/endSection instead")
116120
fun logSection(label: String) {
117121
if (!isCurrentlyTracing) {
118122
return
@@ -124,6 +128,7 @@ object SafeTrace {
124128
/**
125129
* @see [logSection]
126130
*/
131+
@Deprecated("Call androidx.tracing.Trace.beginSection/endSection instead")
127132
@JvmStatic
128133
inline fun logSection(crossinline labelLambda: () -> String) {
129134
if (!isCurrentlyTracing) {
@@ -141,6 +146,7 @@ object SafeTrace {
141146
* ensure that beginSection / endSection pairs are properly nested and called from the same
142147
* thread.
143148
*/
149+
@Deprecated("Call androidx.tracing.Trace.endSection instead", ReplaceWith("endSection", "androidx.tracing.Trace.endSection"))
144150
@JvmStatic
145151
fun endSection() {
146152
if (!isCurrentlyTracing) {
@@ -152,6 +158,7 @@ object SafeTrace {
152158
/**
153159
* @see androidx.tracing.Trace.beginAsyncSection
154160
*/
161+
@Deprecated("Call androidx.tracing.Trace.beginAsyncSection instead", ReplaceWith("beginAsyncSection", "androidx.tracing.Trace.beginAsyncSection"))
155162
@JvmStatic
156163
inline fun beginAsyncSection(
157164
crossinline labelCookiePairLambda: () -> Pair<String, Int>
@@ -167,6 +174,7 @@ object SafeTrace {
167174
* [cookie] defaults to 0 (cookie is used for async traces that overlap)
168175
* @see androidx.tracing.Trace.beginAsyncSection
169176
*/
177+
@Deprecated("Call androidx.tracing.Trace.beginAsyncSection instead", ReplaceWith("beginAsyncSection", "androidx.tracing.Trace.beginAsyncSection"))
170178
@JvmStatic
171179
fun beginAsyncSection(
172180
label: String,
@@ -182,6 +190,7 @@ object SafeTrace {
182190
* [cookie] defaults to 0 (cookie is used for async traces that overlap)
183191
* @see androidx.tracing.Trace.endAsyncSection
184192
*/
193+
@Deprecated("Call androidx.tracing.Trace.endAsyncSection instead", ReplaceWith("endAsyncSection", "androidx.tracing.Trace.endAsyncSection"))
185194
@JvmStatic
186195
fun endAsyncSection(
187196
label: String,
@@ -196,6 +205,7 @@ object SafeTrace {
196205
/**
197206
* @see androidx.tracing.Trace.beginAsyncSection
198207
*/
208+
@Deprecated("Call androidx.tracing.Trace.endAsyncSection instead", ReplaceWith("endAsyncSection", "androidx.tracing.Trace.endAsyncSection"))
199209
@JvmStatic
200210
inline fun endAsyncSection(
201211
crossinline labelCookiePairLambda: () -> Pair<String, Int>

papa-safetrace/src/main/java/papa/SafeTraceFunctions.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import papa.SafeTrace.isTraceable
88
* [label] a string producing lambda if the label is computed dynamically. If the label isn't
99
* dynamic, use the [safeTrace] which directly takes a string instead.
1010
*/
11+
@Deprecated("Call androidx.tracing.trace instead", ReplaceWith("trace", "androidx.tracing.trace"))
1112
inline fun <T> safeTrace(
1213
crossinline label: () -> String,
1314
crossinline block: () -> T
@@ -26,6 +27,7 @@ inline fun <T> safeTrace(
2627
/**
2728
* Allows tracing of a block of code
2829
*/
30+
@Deprecated("Call androidx.tracing.trace instead", ReplaceWith("trace", "androidx.tracing.trace"))
2931
inline fun <T> safeTrace(
3032
label: String,
3133
crossinline block: () -> T

papa-safetrace/src/main/java/papa/SafeTraceSetup.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ object SafeTraceSetup {
1313

1414
fun init(application: Application) {
1515
this.application = application
16+
enableMainThreadMessageTracing()
17+
}
18+
19+
fun enableMainThreadMessageTracing() {
1620
SafeTraceMainThreadMessages.enableMainThreadMessageTracing()
1721
}
1822

0 commit comments

Comments
 (0)