Class ClientMdc
java.lang.Object
com.loomcache.client.diagnostics.ClientMdc
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 identityrequestId— the per-request correlation id (sent on the wire, set on the server when the response is processed)peer— thehost:portof 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAutoCloseable MDC scope; safe to nest. -
Field Summary
Fields -
Method Summary
-
Field Details
-
KEY_CLIENT_ID
- See Also:
-
KEY_REQUEST_ID
- See Also:
-
KEY_PEER
- See Also:
-
-
Method Details
-
scope
Open an MDC scope. Each non-null argument becomes an MDC key for the duration of the returnedClientMdc.MdcScope. Pre-existing values for those keys are saved and restored onClientMdc.MdcScope.close().
-