public class CorrelationIdUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
CORRELATION_ID_FIELD |
static String |
CORRELATION_ID_HEADER_KEY |
static String |
CORRELATION_ID_HEADER_KEY_ALIAS |
static String |
CORRELATION_ID_UNKNOWN |
Modifier and Type | Method and Description |
---|---|
static void |
clearMDC()
Removes the correlation id field from the
MDC . |
static String |
getCorrelationId(ParameterInfo parameterInfo)
Returns the correlation id if already existing, or null if not.
|
static String |
getFromMDC()
Gets a correlation id value from the MDC, if existing, or null otherwise.
|
static String |
getOrGenerateCorrelationId(ParameterInfo parameterInfo)
Returns the correlation id if already existing, or generates a new one
otherwise.
|
static boolean |
mdcHasEntry()
Checks whether there's a correlation id entry in the
MDC . |
static void |
putInMDC(String correlationId)
Puts the provided correlation id into the
MDC under the key
"correlation_id". |
public static final String CORRELATION_ID_HEADER_KEY
public static final String CORRELATION_ID_HEADER_KEY_ALIAS
public static final String CORRELATION_ID_FIELD
public static final String CORRELATION_ID_UNKNOWN
public static boolean mdcHasEntry()
MDC
.public static void putInMDC(String correlationId)
MDC
under the key
"correlation_id".correlationId
- the correlation idpublic static String getFromMDC()
public static void clearMDC()
MDC
.public static String getOrGenerateCorrelationId(ParameterInfo parameterInfo)
parameterInfo
- parameter info to fall back to if correlation id does
not exist in MDCpublic static String getCorrelationId(ParameterInfo parameterInfo)
parameterInfo
- parameter info to fall back to if correlation id does
not exist in MDC, nullableCopyright © 2023. All rights reserved.