Koin Built-in Performance Monitoring with @Monitor
The @Monitor annotation (available since Koin Annotations 2.2.0) enables automatic performance monitoring and tracing for your Koin components through the Kotzilla Platform, the official tooling platform for Koin.
Setup
Add the Kotzilla SDK dependency:
dependencies {
implementation "io.kotzilla:kotzilla-core:latest.version"
}
Check the latest version on the Kotzilla documentation.
Configure the allOpen plugin to make monitored classes extensible:
plugins {
id "org.jetbrains.kotlin.plugin.allopen"
}
allOpen {
annotation("org.koin.core.annotation.Monitor")
}
Initialize Kotzilla analytics in your Koin configuration:
import io.kotzilla.sdk.analytics.koin.analytics
fun initKoin() {
startKoin {
// Enable Kotzilla monitoring
analytics()
modules(appModule)
}
}
Basic Usage
Simply annotate your Koin components with @Monitor:
@Monitor
@Single
class UserService(private val userRepository: UserRepository) {
fun findUser(id: String): User? = userRepository.findById(id)
suspend fun createUser(userData: UserData): User {
return userRepository.save(userData)
}
}