mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-09 08:57:17 +08:00
feat(trace): 新增链路追踪模块(原 web 模块内组件)
This commit is contained in:
28
continew-starter-trace/pom.xml
Normal file
28
continew-starter-trace/pom.xml
Normal 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>
|
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package top.continew.starter.web.autoconfigure.trace;
|
package top.continew.starter.trace.autoconfigure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TLog 配置属性
|
* TLog 配置属性
|
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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.TLogIdGenerator;
|
||||||
import com.yomahub.tlog.id.TLogIdGeneratorLoader;
|
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.context.annotation.Primary;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import top.continew.starter.core.constant.PropertiesConstants;
|
import top.continew.starter.core.constant.PropertiesConstants;
|
||||||
|
import top.continew.starter.trace.filter.TLogServletFilter;
|
||||||
|
import top.continew.starter.trace.handler.TraceIdGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 链路跟踪自动配置
|
* 链路追踪自动配置
|
||||||
*
|
*
|
||||||
* @author Jasmine
|
* @author Jasmine
|
||||||
* @author Charles7c
|
* @author Charles7c
|
||||||
@@ -43,7 +45,7 @@ import top.continew.starter.core.constant.PropertiesConstants;
|
|||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@ConditionalOnWebApplication
|
@ConditionalOnWebApplication
|
||||||
@EnableConfigurationProperties(TraceProperties.class)
|
@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 {
|
public class TraceAutoConfiguration {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(TraceAutoConfiguration.class);
|
private static final Logger log = LoggerFactory.getLogger(TraceAutoConfiguration.class);
|
||||||
@@ -89,6 +91,6 @@ public class TraceAutoConfiguration {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void postConstruct() {
|
public void postConstruct() {
|
||||||
log.debug("[ContiNew Starter] - Auto Configuration 'Web-Trace' completed initialization.");
|
log.debug("[ContiNew Starter] - Auto Configuration 'Trace' completed initialization.");
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -14,23 +14,23 @@
|
|||||||
* limitations under the License.
|
* 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.ConfigurationProperties;
|
||||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||||
import top.continew.starter.core.constant.PropertiesConstants;
|
import top.continew.starter.core.constant.PropertiesConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 链路跟踪配置属性
|
* 链路追踪配置属性
|
||||||
*
|
*
|
||||||
* @author Charles7c
|
* @author Charles7c
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(PropertiesConstants.WEB_TRACE)
|
@ConfigurationProperties(PropertiesConstants.TRACE)
|
||||||
public class TraceProperties {
|
public class TraceProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否启用链路跟踪配置
|
* 是否启用链路追踪配置
|
||||||
*/
|
*/
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
|
@@ -14,13 +14,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package top.continew.starter.web.autoconfigure.trace;
|
package top.continew.starter.trace.filter;
|
||||||
|
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import com.yomahub.tlog.context.TLogContext;
|
import com.yomahub.tlog.context.TLogContext;
|
||||||
import jakarta.servlet.*;
|
import jakarta.servlet.*;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import top.continew.starter.trace.autoconfigure.TraceProperties;
|
||||||
|
import top.continew.starter.trace.handler.TLogWebCommon;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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.constant.TLogConstants;
|
||||||
import com.yomahub.tlog.core.rpc.TLogLabelBean;
|
import com.yomahub.tlog.core.rpc.TLogLabelBean;
|
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* 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.TLogIdGenerator;
|
||||||
import com.yomahub.tlog.id.snowflake.UniqueIdGenerator;
|
import com.yomahub.tlog.id.snowflake.UniqueIdGenerator;
|
@@ -0,0 +1 @@
|
|||||||
|
top.continew.starter.trace.autoconfigure.TraceAutoConfiguration
|
Reference in New Issue
Block a user