It would be nice to have a normalized log prefix all throughout the code:
Each component is present if applicable:
cluster name: the name set through the API
session id: a unique identifier (counter?), maybe the logged keyspace as well
request id: a unique identifier (the CqlRequestHandler's hashCode should be good enough)
execution index: 0 for the initial execution, 1-n for speculative executions. It already exists in the code.
connection id: the remote address and port, maybe the local port as well
stream id: the stream id when applicable
One challenging aspect is that we don't want this to break encapsulation, e.g. a connection should not have a reference to its session just to retrieve its id. We can solve that by passing an agnostic String logPrefix to constructors.
Can't this be achieved with MDC?
Not really, because the MDC is thread-local, whereas our components can live on multiple threads (e.g. a request handler).
This would be super awesome