TelemetryCollector
interface TelemetryCollector
Collects execution metrics for background tasks.
Install a TelemetryCollector on your KmpWorker to track execution timing, success rates, retry counts, and error patterns across all tasks.
val telemetry = SqlDelightTelemetryCollector(database)
val worker = AndroidKmpWorker(context, telemetry = telemetry)
// Query history
val records = telemetry.getHistory(limit = 50)
val failedRecords = telemetry.getHistory(limit = 10, stateFilter = "FAILED")Content copied to clipboard
Functions
Link copied to clipboard
Removes all execution history records.
Link copied to clipboard
abstract suspend fun getHistory(limit: Int = 100, stateFilter: String? = null): List<ExecutionRecord>
Returns execution records, most recent first.
Link copied to clipboard
abstract suspend fun onTaskCompleted(taskId: String, state: TaskState, timestamp: Long, retryCount: Int)
Records the completion of a task execution.
Link copied to clipboard
Records the start of a task execution.
Link copied to clipboard
Removes records older than olderThanMillis milliseconds.