Skip to content

Commit

Permalink
🔖 3.2.0-SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
lltx committed Mar 7, 2024
1 parent 37f8d31 commit 672e17e
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 235 deletions.
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@

支持组件:

- zuul 调用
- spring cloud gateway 调用
- feign 调用
- restTemplate 调用
- dobbo 调用

日志输出格式:

```
2022-04-09 22:16:05.796 INFO [log-trace-service-a-demo,ac8ffaaed5f343da,log-trace-zuul-demo,,] 88948 --- [nio-8081-exec-7] c.p.l.t.service.a.demo.TestController : controller test2 执行 ac8ffaaed5f343da
2022-04-09 22:16:05.569 INFO [log-trace-service-a-demo,04cf5392dc5c4881,log-trace-zuul-demo,,] 88948 --- [nio-8081-exec-9] c.p.l.t.service.a.demo.TestController : controller test2 执行 04cf5392dc5c4881
2022-04-09 22:16:05.183 INFO [log-trace-service-a-demo,86b5c555ce4f4451,log-trace-zuul-demo,,] 88948 --- [nio-8081-exec-1] c.p.l.t.service.a.demo.TestController : controller test2 执行 86b5c555ce4f4451
2022-04-09 22:16:05.796 INFO [log-trace-service-a-demo,ac8ffaaed5f343da,log-trace-gateway-demo,,] 88948 --- [nio-8081-exec-7] c.p.l.t.service.a.demo.TestController : controller test2 执行 ac8ffaaed5f343da
2022-04-09 22:16:05.569 INFO [log-trace-service-a-demo,04cf5392dc5c4881,log-trace-gateway-demo,,] 88948 --- [nio-8081-exec-9] c.p.l.t.service.a.demo.TestController : controller test2 执行 04cf5392dc5c4881
2022-04-09 22:16:05.183 INFO [log-trace-service-a-demo,86b5c555ce4f4451,log-trace-gateway-demo,,] 88948 --- [nio-8081-exec-1] c.p.l.t.service.a.demo.TestController : controller test2 执行 86b5c555ce4f4451
```

我们可以通过 `86b5c555ce4f4451` id 进行查询链路上的所有日志信息。

`log-trace-service-a-demo` 为当前应用。
`log-trace-zuul-demo` 为上游应用。
`log-trace-gateway-demo` 为上游应用。

当然这些参数可以基于业务定制的。

Expand All @@ -34,38 +33,38 @@
```
<dependency>
<groupId>com.pig4cloud.plugin</groupId>
<artifactId>log-trace-spring-boot-starter</artifactId>
<version>3.0.0</version>
<artifactId>log-trace-spring-boot3-starter</artifactId>
<version>3.2.0</version>
</dependency>
```

### 配置应用

这里以3个微服务来举例子。

1. `log-trace-zuul-demo` 充当网关功能
1. `log-trace-gateway-demo` 充当网关功能
2. `log-trace-service-a-demo` 充当服务A
3. `log-trace-service-b-demo` 充当服务B

**调用链路为:**

`log-trace-zuul-demo` -> `log-trace-service-a-demo` `TestController#test`
`log-trace-gateway-demo` -> `log-trace-service-a-demo` `TestController#test`
-> `log-trace-service-b-demo` `TestController#test`

访问网关地址: `http://127.0.0.1:8000/a/test`

**网关日志如下:**

```
2022-04-09 22:16:05.434 DEBUG [33b07a9c5f324375,this] 89996 --- [nio-8000-exec-1] c.p.l.t.s.i.zuul.TracePreZuulFilter : zuul traceid 33b07a9c5f324375
2022-04-09 22:16:05.434 DEBUG [33b07a9c5f324375,this] 89996 --- [nio-8000-exec-1] c.p.l.t.s.i.gateway.TracePregatewayFilter : gateway traceid 33b07a9c5f324375
```

网关转发至服务A

**服务A 日志如下:**

```
2022-04-09 22:16:05.476 INFO [log-trace-service-a-demo,33b07a9c5f324375,log-trace-zuul-demo,,] 88948 --- [nio-8081-exec-5] c.p.l.t.service.a.demo.TestController : controller test2 执行 33b07a9c5f324375
2022-04-09 22:16:05.476 INFO [log-trace-service-a-demo,33b07a9c5f324375,log-trace-gateway-demo,,] 88948 --- [nio-8081-exec-5] c.p.l.t.service.a.demo.TestController : controller test2 执行 33b07a9c5f324375
```

服务A 调用 服务B
Expand Down Expand Up @@ -106,5 +105,5 @@ spring.trace.log.format=X-B3-TraceId,X-B3-ParentName
日志输出如下:

```
2022-04-09 22:15:57.434 DEBUG [33b07a9c5f324375,this] 89996 --- [nio-8000-exec-1] c.p.l.t.s.i.zuul.TracePreZuulFilter : zuul traceid 33b07a9c5f324375
2022-04-09 22:15:57.434 DEBUG [33b07a9c5f324375,this] 89996 --- [nio-8000-exec-1] c.p.l.t.s.i.gateway.TracePregatewayFilter : gateway traceid 33b07a9c5f324375
```
20 changes: 4 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<groupId>com.pig4cloud.plugin</groupId>
<artifactId>log-trace-spring-boot-starter</artifactId>
<version>3.0.0</version>
<artifactId>log-trace-spring-boot3-starter</artifactId>
<version>3.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>log-trace-spring-boot-starter</name>
Expand Down Expand Up @@ -42,8 +42,8 @@
</scm>

<properties>
<spring-boot.version>3.0.0</spring-boot.version>
<spring-cloud.version>2021.0.5</spring-cloud.version>
<spring-boot.version>3.2.3</spring-boot.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
<zuul.version>2.2.10.RELEASE</zuul.version>
<dubbo.version>3.0.5</dubbo.version>
<spring.checkstyle.plugin>0.0.23</spring.checkstyle.plugin>
Expand Down Expand Up @@ -89,18 +89,6 @@
<artifactId>spring-cloud-starter-gateway</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<version>${zuul.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
<optional>true</optional>
</dependency>
</dependencies>


Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -14,7 +13,7 @@
* @since 1.0
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ Client.class, FeignContext.class, TraceContentFactory.class })
@ConditionalOnClass({ Client.class, FeignAutoConfiguration.class, TraceContentFactory.class })
@AutoConfigureBefore(FeignAutoConfiguration.class)
public class TraceFeignClientAutoConfiguration {

Expand Down

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter

This file was deleted.

7 changes: 2 additions & 5 deletions src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ com.pig4cloud.trace.instrument.servlet.TraceServletConfiguration,\
com.pig4cloud.trace.instrument.reactive.TraceReactiveConfiguration,\
com.pig4cloud.trace.instrument.gateway.TraceGatewayAutoConfiguration,\
com.pig4cloud.trace.instrument.feign.TraceFeignClientAutoConfiguration,\
com.pig4cloud.trace.instrument.zuul.TraceZuulAutoConfiguration,\
com.pig4cloud.trace.instrument.resttemplate.TraceRestTemplateConfiguration,\
com.pig4cloud.trace.instrument.dubbo.TraceDubboConfiguration
com.pig4cloud.trace.instrument.resttemplate.TraceRestTemplateConfiguration

# Environment Post Processor
org.springframework.boot.env.EnvironmentPostProcessor=\
com.pig4cloud.trace.processor.TraceEnvironmentPostProcessor,\
com.pig4cloud.trace.instrument.dubbo.TraceDubboEnvironmentPostProcessor
com.pig4cloud.trace.processor.TraceEnvironmentPostProcessor

0 comments on commit 672e17e

Please sign in to comment.