mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-30 02:45:08 +08:00
完成操作日志的记录
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package cn.iocoder.dashboard.framework.tracer.core.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 链路追踪工具类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public class TracerUtils {
|
||||
|
||||
/**
|
||||
* 获得链路追踪编号
|
||||
*
|
||||
* 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。
|
||||
*
|
||||
* 默认情况下,我们使用 Apache SkyWalking 的 traceId 作为链路追踪编号。当然,可能会存在并未引入 Skywalking 的情况,此时使用 UUID 。
|
||||
*
|
||||
* @return 链路追踪编号
|
||||
*/
|
||||
public static String getTraceId() {
|
||||
// 通过 SkyWalking 获取链路编号
|
||||
try {
|
||||
String traceId = TraceContext.traceId();
|
||||
if (StrUtil.isNotBlank(traceId)) {
|
||||
return traceId;
|
||||
}
|
||||
} catch (Throwable ignore) {}
|
||||
// TODO 芋艿 多次调用会问题
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 链路追踪
|
||||
*
|
||||
* 主要目的,是生成全局的链路追踪编号
|
||||
*/
|
||||
package cn.iocoder.dashboard.framework.tracer;
|
Reference in New Issue
Block a user