Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions workflow-tracing-papa/api/workflow-tracing-papa.api
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
public final class com/squareup/workflow1/tracing/papa/PapaSafeTrace : com/squareup/workflow1/tracing/SafeTraceInterface {
public fun <init> ()V
public fun <init> (Z)V
public synthetic fun <init> (ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin generates this when you have parameters with default values - see https://stackoverflow.com/a/53912965 for details

public fun beginAsyncSection (Ljava/lang/String;I)V
public fun beginSection (Ljava/lang/String;)V
public fun endAsyncSection (Ljava/lang/String;I)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import papa.SafeTrace

/**
* Production implementation of [SafeTraceInterface] that delegates to the actual [SafeTrace].
*
* @param isTraceable Whether tracing is enabled. Clients should configure this directly.
* Defaults to false for backwards compatibility.
*/
class PapaSafeTrace : SafeTraceInterface {
override val isTraceable: Boolean
get() = SafeTrace.isTraceable
class PapaSafeTrace(
override val isTraceable: Boolean = false
) : SafeTraceInterface {

override val isCurrentlyTracing: Boolean
get() = SafeTrace.isCurrentlyTracing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ import kotlin.reflect.KType
* [WorkflowRuntimeTracer] plugin to add [SafeTraceInterface] traces.
* By default this uses [PapaSafeTrace] which will use [androidx.tracing.Trace] calls that
* will be received by the system and included in Perfetto traces.
*
* @param safeTrace The [SafeTraceInterface] implementation to use for tracing.
*/
class WorkflowPapaTracer(
private val safeTrace: SafeTraceInterface = PapaSafeTrace()
private val safeTrace: SafeTraceInterface = PapaSafeTrace(isTraceable = false)
) : WorkflowRuntimeTracer() {

private data class NameAndCookie(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ internal class WorkflowPapaTracerTest {
assertNotNull(papaTracer)
}

@Test
fun `PapaSafeTrace can be configured with isTraceable`() {
val traceableTrace = PapaSafeTrace(isTraceable = true)
assertEquals(true, traceableTrace.isTraceable)

val nonTraceableTrace = PapaSafeTrace(isTraceable = false)
assertEquals(false, nonTraceableTrace.isTraceable)
}

@Test
fun `WorkflowPapaTracer can be configured with custom SafeTrace`() {
val customTrace = FakeSafeTrace(isTraceable = true)
val tracer = WorkflowPapaTracer(safeTrace = customTrace)
assertNotNull(tracer)
}

@Test
fun `onPropsChanged delegates to proceed function`() {
val testWorkflow = TestWorkflow()
Expand Down
Loading