Open grassehh opened 10 months ago
Yes definitely an important feature to have with regards to distributed tracing. Had the same issue and took me some time to figure it out.
@grassehh Does this solution logs twice the Outgoing Request
and Incoming Response
for you?
Detailed Description
Important note: This issue is only about client calls, because even though this is also useful for server logs, there is currently an issue for server logs here
Currently, in order to have the MDC logged inside Spring
WebClient
request/response logs, when usinglogbook-logstash
, it is necessary to wrap theLogbookClientHandler
with a customChannelDuplexHandler
Context
This change would make it easier to configure context propagation when using Logbook Netty with Spring Webflux. Logging MDC context in logstash logs is particularly useful when combined with tool like Datadog, which natively parses JSON formatted logs and extracts event attributes as facets. When using observation library like micrometer-tracing, it is then as easy as adding a baggage before calling the logger. This baggage is then available in Datadog as an Event Attribute.
Possible Implementation
Maybe add a property like
logbook.context-propagation: true
which when enabled, instrumentate the WebClient to propagate the MDC context to be logged inside WebClient.Your Environment
Sample available here