当前位置:网站首页>Tlog helps Pangu framework realize microservice link log tracking

Tlog helps Pangu framework realize microservice link log tracking

2022-06-25 22:20:00 InfoQ

With the popularity of microservices , Many companies break down their systems into many micro services according to their business boundaries . Therefore, the service link runs through many microservice nodes , As a result, it becomes very difficult to locate the logs of a request and upstream and downstream services . To solve this pain ,  There are also many mature solutions in the industry . Such as  SkyWalking,Pinpoint  etc. , But its operation and maintenance costs and data storage costs can not be underestimated . If there are corresponding resources to do so, they are naturally the best choice .  But if you have limited resources , So here is a very lightweight integration  TLog  To solve the problem of log tracking .

TLog  What is it? ?

TLog  Provides the simplest way to solve the problem of log tracking , It doesn't collect logs , There's no need for additional storage space , It just automatically tags your logs , Automatic generation  TraceId  Throughout the entire link of your microservice . And provide upstream and downstream node information .

Integrate  TLog

Pangu development framework has  TLog  Integrated into the Pangu foundation module as the default standard component :
pangu-spring-boot-starter
.

How to use

First step : Rely on Pangu basic module

<dependency>
 <groupId>com.gitee.pulanos.pangu</groupId>
 <artifactId>pangu-spring-boot-starter</artifactId>
</dependency>

The second step : The startup class invokes the log enhancement method

static {
 AspectLogEnhance.enhance();
}

The third step : Construct Pangu consumer micro service and producer micro service respectively

See the following Pangu example module .
Get the code

  • pangu-examples-dubbo-service  Service producer
  • pangu-examples-webapi-dubbo-service-based  Serving consumers

View the log output effect

We're in a  Dubbo  Serving consumers and a  Dubbo  After the above configurations are made in the service producer application , You can see in the log of each call chain  TLog  Custom embedded  TraceId  Label value  
10812814178142336
. As shown below .

The consumer end :
2022-06-23 14:40:50 INFO 47050 - [nio-8080-exec-1] c.x.DemoController : < 0 >< 10812814178142336 > call case1...
Production end :
2022-06-23 14:40:50 INFO 46395 - [:20881-thread-4] c.x.UserServiceImpl : < 0.1 >< 10812814178142336 >  Parameters userIn:UserInDto(name=null, userType=1)

原网站

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251838500320.html