Skip to content

Commit

Permalink
Polish the doc
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-sheng authored and darknesstm committed Jul 7, 2023
1 parent a0f5818 commit 6c7c254
Showing 1 changed file with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Mannual propagation of tracing context for Webflux
* Dependency the toolkit, such as using maven or gradle
# Webflux Tracing Assistant APIs

These APIs provide advanced features to enhance interaction capabilities in Webflux cases.

Add the toolkit to your project dependency, through Maven or Gradle
```xml
<dependency>
<groupId>org.apache.skywalking</groupId>
Expand All @@ -8,7 +11,11 @@
</dependency>
```

* usage 1.
The following scenarios are supported for tracing assistance.

### Continue Tracing from Client
The `WebFluxSkyWalkingOperators#continueTracing` provides manual tracing continuous capabilities to adopt native Webflux APIs

```java
@GetMapping("/testcase/annotation/mono/onnext")
public Mono<String> monoOnNext(@RequestBody(required = false) String body) {
Expand All @@ -19,7 +26,7 @@
}));
}
```
* usage 2.

```java
@GetMapping("/login/userFunctions")
public Mono<Response<FunctionInfoResult>> functionInfo(ServerWebExchange exchange, @RequestParam String userId) {
Expand All @@ -34,7 +41,6 @@
}
```

* usage 3.
```java
Mono.just("key").subscribeOn(Schedulers.boundedElastic())
.doOnEach(WebFluxSkyWalkingOperators.continueTracing(SignalType.ON_NEXT, () -> log.info("test log with tid")))
Expand All @@ -46,14 +52,23 @@
...
```

* usage 4.
### Fetch trace context relative IDs
```java
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain){
// get traceId
// fetch trace ID
String traceId = WebFluxSkyWalkingTraceContext.traceId(exchange);

// set correlation data, it can be retrieved by downstream nodes.
return chain.filter(exchange);
}
```

### Manipulate Correlation Context

```java
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain){
// Set correlation data can be retrieved by upstream nodes.
WebFluxSkyWalkingTraceContext.putCorrelation(exchange, "key", "value");
return chain.filter(exchange);
}
Expand Down

0 comments on commit 6c7c254

Please sign in to comment.