Package com.sap.cds.services.utils
Class CorrelationIdUtils
java.lang.Object
com.sap.cds.services.utils.CorrelationIdUtils
Utility for retrieving or generating a correlation id.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclearMDC()Removes the correlation id field from theMDC.static StringgetCorrelationId(ParameterInfo parameterInfo) Returns the correlation id if already existing, or null if not.static StringGets a correlation id value from the MDC, if existing, or null otherwise.static StringgetOrGenerateCorrelationId(ParameterInfo parameterInfo) Returns the correlation id if already existing, or generates a new one otherwise.static booleanChecks whether there's a correlation id entry in theMDC.static voidPuts the provided correlation id into theMDCunder the key "correlation_id".
-
Field Details
-
CORRELATION_ID_HEADER_KEY
- See Also:
-
CORRELATION_ID_HEADER_KEY_ALIAS
- See Also:
-
CORRELATION_ID_FIELD
- See Also:
-
CORRELATION_ID_UNKNOWN
- See Also:
-
-
Method Details
-
mdcHasEntry
public static boolean mdcHasEntry()Checks whether there's a correlation id entry in theMDC.- Returns:
- true, if there's an entry under the key "correlation_id"
-
putInMDC
Puts the provided correlation id into theMDCunder the key "correlation_id".- Parameters:
correlationId- the correlation id
-
getFromMDC
Gets a correlation id value from the MDC, if existing, or null otherwise.- Returns:
- a correlation id
-
clearMDC
public static void clearMDC()Removes the correlation id field from theMDC. -
getOrGenerateCorrelationId
Returns the correlation id if already existing, or generates a new one otherwise.Tries to retrieve an existing correlation id from a MDC field, or the parameter info headers, in that specific order.
- Parameters:
parameterInfo- parameter info to fall back to if correlation id does not exist in MDC- Returns:
- a correlation id
-
getCorrelationId
Returns the correlation id if already existing, or null if not.- Parameters:
parameterInfo- parameter info to fall back to if correlation id does not exist in MDC, nullable- Returns:
- a correlation id
-