Hierarchical logging

Description

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.

Environment

None

Pull Requests

None

Activity

Show:
Alexandre Dutra
June 18, 2017, 8:44 AM

Can't this be achieved with MDC?

Olivier Michallat
June 19, 2017, 3:12 PM

Not really, because the MDC is thread-local, whereas our components can live on multiple threads (e.g. a request handler).

Andy Tolbert
June 19, 2017, 3:20 PM

This would be super awesome

Fixed

Assignee

Olivier Michallat

Reporter

Olivier Michallat

Labels

None

PM Priority

None

Affects versions

None

Fix versions

Pull Request

None

Doc Impact

None

Size

None

External issue ID

None

External issue ID

None

Priority

Minor
Configure