Skip to content

WiretapConfig

WiretapConfig is the shared configuration class used by both Ktor and OkHttp plugins.

Properties

enabled

Type: BooleanDefault: true

Master switch. When false, the plugin passes requests through without any logging, rule evaluation, or overhead.

install(WiretapKtorHttpPlugin) {
    enabled = BuildConfig.DEBUG
}

shouldLog

Type: (url: String, method: String) -> BooleanDefault: { _, _ -> true }

Filter which requests are captured in the log database. Evaluated before any DB write.

shouldLog = { url, method ->
    url.contains("/api/") && method != "OPTIONS"
}

Note

Requests that don't pass shouldLog are still subject to mock/throttle rules — they just won't appear in the inspector.

headerAction

Type: (key: String) -> HeaderActionDefault: { HeaderAction.Keep }

Controls how each header is treated in logged data. Called for every header key in both requests and responses. See Header Actions for details.

headerAction = { key ->
    when {
        key.equals("Authorization", ignoreCase = true) -> HeaderAction.Mask()
        key.equals("Cookie", ignoreCase = true) -> HeaderAction.Skip
        else -> HeaderAction.Keep
    }
}

logRetention

Type: LogRetentionDefault: LogRetention.Forever

Controls how long log entries are retained. See Log Retention for details.

logRetention = LogRetention.Days(7)

maxContentLength

Type: IntDefault: 512000 (500 KB)

Maximum number of characters to store for request and response bodies. Bodies exceeding this limit are truncated before being saved to the database. Capped at 500 * 1024 (500 KB). Set to 0 to skip body logging entirely.

maxContentLength = 100 * 1024 // 100 KB

Usage by Plugin

install(WiretapKtorHttpPlugin) {
    enabled = true
    shouldLog = { url, _ -> url.contains("/api/") }
    headerAction = { key -> HeaderAction.Keep }
    logRetention = LogRetention.AppSession
    maxContentLength = 100 * 1024
}
WiretapOkHttpInterceptor {
    enabled = true
    shouldLog = { url, _ -> url.contains("/api/") }
    headerAction = { key -> HeaderAction.Keep }
    logRetention = LogRetention.AppSession
    maxContentLength = 100 * 1024
}