Package io.ktor.server.plugins.callid


Link copied to clipboard
class CallIdConfig

A configuration for the CallId plugin.

Link copied to clipboard
typealias CallIdProvider = (<ERROR CLASS>) -> String?

A function that retrieves or generates call id using provided call

Link copied to clipboard
typealias CallIdVerifier = (String) -> Boolean

A function that verifies retrieved or generated call id. Should return true for a valid call id. Also it could throw a RejectedCallIdException to reject an ApplicationCall otherwise an illegal call id will be ignored or replaced with generated one.

Link copied to clipboard
class RejectedCallIdException(illegalCallId: String) : IllegalArgumentException, CopyableThrowable<RejectedCallIdException>

An exception that could be thrown to reject a call due to illegal call id


Link copied to clipboard
fun CallLoggingConfig.callIdMdc(name: String = "CallId")

Put call id into MDC (diagnostic context value) with name

Link copied to clipboard
fun CallIdConfig.generate(length: Int = 64, dictionary: String = CALL_ID_DEFAULT_DICTIONARY)

Generates a fixed length call ID using the specified dictionary. Note that this function generates pseudo-random identifiers via regular java.util.Random and should not be considered as cryptographically secure. Also note that you need to use the same dictionary for CallIdVerifier, otherwise a generated call ID could be discarded or may lead to complete call rejection.


Link copied to clipboard

The default call ID's generator dictionary.

Link copied to clipboard
val CallId: <ERROR CLASS><CallIdConfig>

A plugin that allows you to trace client requests end-to-end by using unique request IDs or call IDs. Typically, working with a call ID in Ktor might look as follows:

Link copied to clipboard
val <ERROR CLASS>.callId: String?

Gets a call ID retrieved or generated by the CallId plugin. Returns null if there is no call ID is provided and no generators are configured.