Class ClientMdc

java.lang.Object
com.loomcache.client.diagnostics.ClientMdc

public final class ClientMdc extends Object
BLK-2026-04-22-010: small helper that sets/clears the SLF4J MDC fields the client logs use for cross-process trace reconstruction.

Keys mirror the server-side MDC (see CacheNode.handleMessage):

  • clientId — the client's own identity
  • requestId — the per-request correlation id (sent on the wire, set on the server when the response is processed)
  • peer — the host:port of the connection servicing the request

Use the try-with-resources idiom:

try (var ignored = ClientMdc.scope(clientId, correlationId, "node-2:5701")) {
    ... do request work ...
}

The ClientMdc.MdcScope closes restore-or-clear semantics: any MDC fields that existed before the scope are restored on close; new fields set inside the scope are cleared.