feat(trace): 新增链路追踪模块(原 web 模块内组件)

This commit is contained in:
2025-03-26 20:41:46 +08:00
parent b5bfe5c681
commit 85285e56a8
8 changed files with 45 additions and 12 deletions

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>top.continew</groupId>
<artifactId>continew-starter</artifactId>
<version>${revision}</version>
</parent>
<artifactId>continew-starter-trace</artifactId>
<description>ContiNew Starter 链路追踪模块</description>
<dependencies>
<!-- Web 模块 -->
<dependency>
<groupId>top.continew</groupId>
<artifactId>continew-starter-web</artifactId>
</dependency>
<!-- TLog轻量级的分布式日志标记追踪神器 -->
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>tlog-web-spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package top.continew.starter.web.autoconfigure.trace;
package top.continew.starter.trace.autoconfigure;
/**
* TLog 配置属性

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package top.continew.starter.web.autoconfigure.trace;
package top.continew.starter.trace.autoconfigure;
import com.yomahub.tlog.id.TLogIdGenerator;
import com.yomahub.tlog.id.TLogIdGeneratorLoader;
@@ -32,9 +32,11 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.core.Ordered;
import top.continew.starter.core.constant.PropertiesConstants;
import top.continew.starter.trace.filter.TLogServletFilter;
import top.continew.starter.trace.handler.TraceIdGenerator;
/**
* 链路踪自动配置
* 链路踪自动配置
*
* @author Jasmine
* @author Charles7c
@@ -43,7 +45,7 @@ import top.continew.starter.core.constant.PropertiesConstants;
@AutoConfiguration
@ConditionalOnWebApplication
@EnableConfigurationProperties(TraceProperties.class)
@ConditionalOnProperty(prefix = PropertiesConstants.WEB_TRACE, name = PropertiesConstants.ENABLED, havingValue = "true")
@ConditionalOnProperty(prefix = PropertiesConstants.TRACE, name = PropertiesConstants.ENABLED, havingValue = "true")
public class TraceAutoConfiguration {
private static final Logger log = LoggerFactory.getLogger(TraceAutoConfiguration.class);
@@ -89,6 +91,6 @@ public class TraceAutoConfiguration {
@PostConstruct
public void postConstruct() {
log.debug("[ContiNew Starter] - Auto Configuration 'Web-Trace' completed initialization.");
log.debug("[ContiNew Starter] - Auto Configuration 'Trace' completed initialization.");
}
}

View File

@@ -14,23 +14,23 @@
* limitations under the License.
*/
package top.continew.starter.web.autoconfigure.trace;
package top.continew.starter.trace.autoconfigure;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import top.continew.starter.core.constant.PropertiesConstants;
/**
* 链路踪配置属性
* 链路踪配置属性
*
* @author Charles7c
* @since 1.3.0
*/
@ConfigurationProperties(PropertiesConstants.WEB_TRACE)
@ConfigurationProperties(PropertiesConstants.TRACE)
public class TraceProperties {
/**
* 是否启用链路踪配置
* 是否启用链路踪配置
*/
private boolean enabled = false;

View File

@@ -14,13 +14,15 @@
* limitations under the License.
*/
package top.continew.starter.web.autoconfigure.trace;
package top.continew.starter.trace.filter;
import cn.hutool.core.text.CharSequenceUtil;
import com.yomahub.tlog.context.TLogContext;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import top.continew.starter.trace.autoconfigure.TraceProperties;
import top.continew.starter.trace.handler.TLogWebCommon;
import java.io.IOException;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package top.continew.starter.web.autoconfigure.trace;
package top.continew.starter.trace.handler;
import com.yomahub.tlog.constant.TLogConstants;
import com.yomahub.tlog.core.rpc.TLogLabelBean;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package top.continew.starter.web.autoconfigure.trace;
package top.continew.starter.trace.handler;
import com.yomahub.tlog.id.TLogIdGenerator;
import com.yomahub.tlog.id.snowflake.UniqueIdGenerator;

View File

@@ -0,0 +1 @@
top.continew.starter.trace.autoconfigure.TraceAutoConfiguration