package cn.axzo.workflow.core.common.utils;

import org.slf4j.MDC;
import org.springframework.util.StringUtils;

import static cn.axzo.workflow.common.constant.LogFieldConstants.X_REQUEST_ID;
import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC;

/**
 * 获取 TraceId
 *
 * @author wangli
 * @since 2024/7/3 10:14
 */
public final class TraceUtil {

    private TraceUtil() {
    }

    public static String traceId() {
        String xRequestId = MDC.get(X_REQUEST_ID);
        return StringUtils.hasText(xRequestId) ? xRequestId : MDC.get(CTX_LOG_ID_MDC);
    }
}
