-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wangyb
committed
Oct 20, 2022
1 parent
f86decd
commit d6dc5a4
Showing
7 changed files
with
109 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
### 查询服务 | ||
GET http://127.0.0.1:9001/imooc/rms-mall-nacos-client/nacos-client/service-instance?serviceId=rms-mall-gateway | ||
Accept: application/json | ||
e-commerce-user: eyJhbGciOiJSUzI1NiJ9.eyJlLWNvbW1lcmNlLXVzZXIiOiJ7XCJpZFwiOjEwLFwidXNlcm5hbWVcIjpcIndhbmd5YkBxcS5jb21cIn0iLCJqdGkiOiJiYTU0MjBjNy0wMTM1LTRhZjYtOGVjYS0wZGUwZmQ5OTI5ZDgiLCJleHAiOjE2NjYxMDg4MDB9.eulJFnRt_I7ycLFhcZVi2wLk8HdWvnHgrXKqBm9j86StFnMl4D4fSFgWGOQoD1dwFgOMT00JhHb77hK1wsxQDMbymIj9iii5m21tNmdRfGY7FbwMh7Bd9M2s3_wkct7xHxcdyQ-z7T_0GgUYRJsT6zpTzBW5bloiltG_V1mqNCxRpvXo9HlztizZg69BaZuVSpoSee-w9g74_cvS9FsZyB9ztu19d6pz-OoByjBbWC0u4F_9TS8zCkWsGpGTReiKiP4MVPVHv44BqAUqJFLsLky7kPRx351tVQDuCNT5mXN0U-Pu4HEOtIV59C8GwvtXJooLAQtsJ5vccF_ax_WkMQ | ||
e-commerce-user: eyJhbGciOiJSUzI1NiJ9.eyJlLWNvbW1lcmNlLXVzZXIiOiJ7XCJpZFwiOjEwLFwidXNlcm5hbWVcIjpcIndhbmd5YkBxcS5jb21cIn0iLCJqdGkiOiJjMWE5MWRmNC0zYjc3LTQ2MjktYjZjNC01M2MwZDYzNDczMzAiLCJleHAiOjE2NjYyODE2MDB9.K2K6WRKIUy3a96CKdxOxMKHDXheZlOaVcc5yglqlGq8Hf5idsJApgT0gE6T13mawrnvafwG0OnI2KHOWX05h8cSfkS25_IXCEFy_Qk-Wyf8pgLCFWQZU4MhIbMqVCzv7WB196fZYunAlr0JaYL2BJRxMr4k2Lu5x2o9y2jTBTkT4Yc1qpfgZEQLM9Ab5s6mszEA36qHFZDlKiT5iT_mVZUbO8aaB-IDhNT5wi5HDeFYkr82C5Q_v7Ic1uwZLWnaZa0wTnFQFr_ouj39itaziUlWtvxaSlmOFCW3n9QMdlVagdaTqpCqeUNGdu5ptEUysrnDgd6eBLSganiS_SKHirA | ||
token: imooc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...s-client/src/main/java/com/wyb/rms/nacos/client/controller/SleuthTraceInfoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.wyb.rms.nacos.client.controller; | ||
|
||
import com.wyb.rms.nacos.client.service.SleuthTraceInfoService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* <h1>打印跟踪信息</h1> | ||
*/ | ||
@Slf4j | ||
@RestController | ||
@RequestMapping("/sleuth") | ||
public class SleuthTraceInfoController { | ||
|
||
private final SleuthTraceInfoService traceInfoService; | ||
|
||
public SleuthTraceInfoController(SleuthTraceInfoService traceInfoService) { | ||
this.traceInfoService = traceInfoService; | ||
} | ||
|
||
/** | ||
* <h2>打印日志跟踪信息</h2> | ||
*/ | ||
@GetMapping("/trace-info") | ||
public void logCurrentTraceInfo() { | ||
traceInfoService.logCurrentTraceInfo(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...l-nacos-client/src/main/java/com/wyb/rms/nacos/client/service/SleuthTraceInfoService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.wyb.rms.nacos.client.service; | ||
|
||
import brave.Tracer; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* <h1>使用代码更直观的看到 Sleuth 生成的相关跟踪信息</h1> | ||
* */ | ||
@Slf4j | ||
@Service | ||
public class SleuthTraceInfoService { | ||
|
||
/** brave.Tracer 跟踪对象 */ | ||
private final Tracer tracer; | ||
|
||
public SleuthTraceInfoService(Tracer tracer) { | ||
this.tracer = tracer; | ||
} | ||
|
||
/** | ||
* <h2>打印当前的跟踪信息到日志中</h2> | ||
* */ | ||
public void logCurrentTraceInfo() { | ||
|
||
log.info("Sleuth trace id: [{}]", tracer.currentSpan().context().traceId()); | ||
log.info("Sleuth span id: [{}]", tracer.currentSpan().context().spanId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters