优化skywalking
This commit is contained in:
parent
a4fa0ac410
commit
c6eb18e839
@ -6,6 +6,7 @@ import org.apache.skywalking.apm.toolkit.trace.Trace;
|
|||||||
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
|
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
|
||||||
import org.apache.skywalking.apm.toolkit.trace.Tracer;
|
import org.apache.skywalking.apm.toolkit.trace.Tracer;
|
||||||
import org.apache.skywalking.apm.toolkit.webflux.WebFluxSkyWalkingOperators;
|
import org.apache.skywalking.apm.toolkit.webflux.WebFluxSkyWalkingOperators;
|
||||||
|
import org.apache.skywalking.apm.toolkit.webflux.WebFluxSkyWalkingTraceContext;
|
||||||
import org.reactivestreams.Subscription;
|
import org.reactivestreams.Subscription;
|
||||||
import org.slf4j.MDC;
|
import org.slf4j.MDC;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -30,12 +31,7 @@ public class LogMdcConfiguration {
|
|||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void contextOperatorHook() {
|
public void contextOperatorHook() {
|
||||||
Hooks.onEachOperator(Log4Constans.PRINT_LOG_ID, Operators.lift((r, c) ->{
|
Hooks.onEachOperator(Log4Constans.PRINT_LOG_ID, Operators.lift((r, c) ->{
|
||||||
Context ctx = c.currentContext();
|
|
||||||
|
|
||||||
if(ctx.hasKey(Log4Constans.PRINT_LOG_ID)){
|
|
||||||
MDC.put(Log4Constans.PRINT_LOG_ID, ctx.get(Log4Constans.PRINT_LOG_ID));
|
|
||||||
//Tracer.createLocalSpan(Log4Constans.PRINT_LOG_ID);
|
|
||||||
}
|
|
||||||
return new MdcContextSubscriber(c);
|
return new MdcContextSubscriber(c);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
@ -81,8 +77,19 @@ public class LogMdcConfiguration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(T t) {
|
public void onNext(T t) {
|
||||||
|
Context ctx = currentContext();
|
||||||
|
|
||||||
coreSubscriber.onNext(t);
|
if(ctx.hasKey(Log4Constans.PRINT_LOG_ID)){
|
||||||
|
MDC.put(Log4Constans.PRINT_LOG_ID, ctx.get(Log4Constans.PRINT_LOG_ID));
|
||||||
|
//String requestId = WebFluxSkyWalkingTraceContext.traceId();
|
||||||
|
//Tracer.createLocalSpan(Log4Constans.PRINT_LOG_ID);
|
||||||
|
|
||||||
|
// return;
|
||||||
|
}
|
||||||
|
WebFluxSkyWalkingOperators.continueTracing(ctx, () ->{
|
||||||
|
coreSubscriber.onNext(t);
|
||||||
|
});
|
||||||
|
//coreSubscriber.onNext(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,4 +39,6 @@ spring:
|
|||||||
host: 192.168.8.146
|
host: 192.168.8.146
|
||||||
port: 32030
|
port: 32030
|
||||||
password: 123456
|
password: 123456
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
|
logging:
|
||||||
|
config: classpath:logback-spring.xml
|
||||||
Loading…
x
Reference in New Issue
Block a user