Network

Network logging for APM and bug reports in KMP (Ktor plugin and NetworkLogger).

Network requests and responses can be logged for APM and bug reports. The KMP library provides:

  1. Luciq Ktor plugin – Intercepts Ktor HttpClient calls, injects W3C trace headers, and logs requests/responses.

  2. NetworkLogger – Manual logging and callbacks for obfuscation and omission.

Ktor plugin

Install the plugin on your HttpClient so all requests and responses are logged and W3C headers are injected:

Kotlin
import ai.luciq.kmp.interceptors.LuciqKtorPlugin

val client = HttpClient(engine) {
    install(LuciqKtorPlugin)
}

No extra code is needed for each request; the plugin handles timing, headers, and body capture (subject to size limits and obfuscation/omission callbacks).

Manual network logging

If you are not using Ktor or need to log a request from another HTTP client, use NetworkLoggerKmp.networkLog with a NetworkData instance. Build NetworkData with your request/response details (URL, method, headers, body, timestamps, status, etc.). See the Network Logging (Ktor) section for obfuscation and omission.

Enable/disable body and auto-masking

Kotlin
NetworkLoggerKmp.setNetworkLogBodyEnabled(true)
NetworkLoggerKmp.setNetworkAutoMaskingEnabled(true)

For full details and W3C header usage, see Network Logging (Ktor) and Obfuscation & Omission.

Last updated