io.aviso.logging.correlation

Defines a minimal namespace containing a dynamic Var used to propogate the correlation id into the logging layer.

*correlation-id*

dynamic

A dynamic var that contains the correlation id used by the %mdc{correlation-id} pattern. Defaults to the empty string.

default-correlation-id-generator

(default-correlation-id-generator request)

The default correlation id generator ignores the request, and returns a random UUID string. Alternate implementations may use information in the request to build a more meaningful or semantic name.

wrap-with-request-correlation

(wrap-with-request-correlation handler)(wrap-with-request-correlation handler header-name correlation-id-generator)

Wraps a handler with logic that obtains the correlation id from the request (if present).

When the id is not present, a new id is generated.

The id (from the request, or as generated) will be available in the *correlation-id* dynamic Var. This will allow code sending requests to other servers to add the necessary header.

The id will be returned in the response.