Package-level declarations

Types

Link copied to clipboard

A configuration for the CallId plugin.

Link copied to clipboard
typealias CallIdProvider = (call: ApplicationCall) -> 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(val illegalCallId: String) : IllegalArgumentException, CopyableThrowable<RejectedCallIdException>

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

Properties

Link copied to clipboard

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

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.

Functions

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.