LogicTracer

Central registry for logic method tracing.

The compiler plugin injects calls to this object's notify methods at the start and end of traced ModuleLogic methods. Observers registered here receive events for all traced method invocations across the application.

Usage:

// Register an observer to receive tracing events
val observer = object : LogicObserver {
override fun onMethodStart(event: LogicMethodStart) {
println("Started: ${event.logicClass}.${event.methodName}")
}
override fun onMethodCompleted(event: LogicMethodCompleted) {
println("Completed: ${event.callId} in ${event.durationMs}ms")
}
override fun onMethodFailed(event: LogicMethodFailed) {
println("Failed: ${event.callId} - ${event.exceptionType}")
}
}

LogicTracer.addObserver(observer)

// Later, when done:
LogicTracer.removeObserver(observer)

See also

for the observer interface

for method start events

for method completion events

for method failure events

Functions

Link copied to clipboard
fun addObserver(observer: LogicObserver)

Registers an observer to receive logic method tracing events.

Link copied to clipboard

Removes all registered observers.

Link copied to clipboard
fun notifyMethodCompleted(callId: String, result: String?, resultType: String, durationMs: Long)

Notifies observers that a traced method completed successfully.

Link copied to clipboard
fun notifyMethodFailed(callId: String, exception: Throwable, durationMs: Long)

Notifies observers that a traced method failed with an exception.

Link copied to clipboard
fun notifyMethodStart(logicClass: String, methodName: String, params: Map<String, String>, sourceFile: String? = null, lineNumber: Int? = null, githubSourceUrl: String? = null): String
Link copied to clipboard

Returns the current number of registered observers.

Link copied to clipboard

Returns the number of pending (in-flight) traced method calls.

Link copied to clipboard

Removes a previously registered observer.