-
Notifications
You must be signed in to change notification settings - Fork 271
Open
Labels
Description
Description
Using LogbookClient from logbook-ktor, the HTTP response log does not preserves the context (for instance MDC) used in the request.
Expected Behavior
Context should be preserved in the HTTP response log
Actual Behavior
Context is missing in the HTTP response log
Possible Fix
In LogbookClient, maybe pass the context of the current coroutine when launching the new coroutine:
...
val (loggingContent, responseContent) = httpResponse.rawContent.split(httpResponse)
scope.launch(coroutineContext) {
val responseProcessingStage = httpResponse.call.attributes[responseProcessingStageKey]
...I tested it locally by forking LogbookClient and it works in my scenario.
Steps to Reproduce
- Configure a ktor HTTP client and install LogbookClient
- Add something in the MDC
- Make a request with the HTTP client
- If you check the response log, it will not contain the MDC.
Context
I'm using context propagation for observability, for example to have a traceId which I can use to view all logs related to it.
Your Environment
logbook-ktor:3.12.2
ktor-client:: 3.2.3