Skip to content

Commit

Permalink
[pinpoint-apm#10492] Update reactor mark error
Browse files Browse the repository at this point in the history
  • Loading branch information
jaehong-kim committed Nov 13, 2023
1 parent ecfb2b6 commit 4b7a556
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 3 deletions.
3 changes: 3 additions & 0 deletions agent/src/main/resources/profiles/local/pinpoint.config
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,10 @@ profiler.reactor-netty.client.param=true

# Set whether to trace the transport error(connection timeout, unknown host, connection refused)
profiler.reactor-netty.client.trace.transport.error=true
profiler.reactor-netty.client.mark.error.transport.error=false
# Set whether to trace the http error(response timeout, read/write timeout)
profiler.reactor-netty.client.trace.http.error=true
profiler.reactor-netty.client.mark.error.http.error=false

###########################################################
# JSP #
Expand Down Expand Up @@ -1101,6 +1103,7 @@ profiler.spring.tx.mark.error=false
profiler.reactor.enable=true
# Set whether to trace the onErrorComplete(), onErrorResume(), onErrorMap(), onErrorReturn() methods
profiler.reactor.trace.onError=false
profiler.reactor.mark.error.onError=false
# Set whether to trace the publishOn(), subscribeOn() methods
profiler.reactor.trace.publishOn=true
profiler.reactor.trace.subscribeOn=true
Expand Down
3 changes: 3 additions & 0 deletions agent/src/main/resources/profiles/release/pinpoint.config
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,10 @@ profiler.reactor-netty.client.param=true

# Set whether to trace the transport error(connection timeout, unknown host, connection refused)
profiler.reactor-netty.client.trace.transport.error=false
profiler.reactor-netty.client.mark.error.transport.error=false
# Set whether to trace the http error(response timeout, read/write timeout)
profiler.reactor-netty.client.trace.http.error=false
profiler.reactor-netty.client.mark.error.http.error=false

###########################################################
# JSP #
Expand Down Expand Up @@ -1099,6 +1101,7 @@ profiler.spring.tx.mark.error=false
profiler.reactor.enable=true
# Set whether to trace the onErrorComplete(), onErrorResume(), onErrorMap(), onErrorReturn() methods
profiler.reactor.trace.onError=false
profiler.reactor.mark.error.onError=false
# Set whether to trace the publishOn(), subscribeOn() methods
profiler.reactor.trace.publishOn=true
profiler.reactor.trace.subscribeOn=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class ReactorNettyPluginConfig {
private final boolean traceHttpError;
private final boolean clientEnable;
private boolean param = true;
private final boolean markErrorTransportError;
private final boolean markErrorHttpError;

public ReactorNettyPluginConfig(ProfilerConfig config) {
Objects.requireNonNull(config, "config");
Expand All @@ -60,7 +62,9 @@ public ReactorNettyPluginConfig(ProfilerConfig config) {

// Reactor
this.traceTransportError = config.readBoolean("profiler.reactor-netty.client.trace.transport.error", false);
this.markErrorTransportError = config.readBoolean("profiler.reactor-netty.client.mark.error.transport.error", false);
this.traceHttpError = config.readBoolean("profiler.reactor-netty.client.trace.http.error", false);
this.markErrorHttpError = config.readBoolean("profiler.reactor-netty.client.mark.error.http.error", false);
}

public boolean isEnable() {
Expand Down Expand Up @@ -111,6 +115,14 @@ public boolean isTraceHttpError() {
return traceHttpError;
}

public boolean isMarkErrorTransportError() {
return markErrorTransportError;
}

public boolean isMarkErrorHttpError() {
return markErrorHttpError;
}

@Override
public String toString() {
return "ReactorNettyPluginConfig{" +
Expand All @@ -126,6 +138,8 @@ public String toString() {
", traceHttpError=" + traceHttpError +
", clientEnable=" + clientEnable +
", param=" + param +
", markErrorTransportError=" + markErrorTransportError +
", markErrorHttpError=" + markErrorHttpError +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@

public class ClientTransportSubscriberInterceptor extends AsyncContextSpanEventSimpleAroundInterceptor {
private final boolean traceTransportError;
private final boolean markErrorTransportError;

public ClientTransportSubscriberInterceptor(TraceContext traceContext, MethodDescriptor methodDescriptor) {
super(traceContext, methodDescriptor);
final ReactorNettyPluginConfig config = new ReactorNettyPluginConfig(traceContext.getProfilerConfig());
this.traceTransportError = config.isTraceTransportError();
this.markErrorTransportError = config.isMarkErrorTransportError();
}

// AsyncContext must exist in Target for tracking.
Expand Down Expand Up @@ -62,7 +64,7 @@ public void afterTrace(AsyncContext asyncContext, Trace trace, SpanEventRecorder
recorder.recordApi(methodDescriptor);
final Throwable argThrowable = ArrayArgumentUtils.getArgument(args, 0, Throwable.class);
if (argThrowable != null) {
recorder.recordException(argThrowable);
recorder.recordException(markErrorTransportError, argThrowable);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@

public class HttpObserverOnUncaughtExceptionInterceptor extends AsyncContextSpanEventSimpleAroundInterceptor {
private final boolean traceHttpError;
private final boolean markErrorHttpError;

public HttpObserverOnUncaughtExceptionInterceptor(TraceContext traceContext, MethodDescriptor methodDescriptor) {
super(traceContext, methodDescriptor);
final ReactorNettyPluginConfig config = new ReactorNettyPluginConfig(traceContext.getProfilerConfig());
this.traceHttpError = config.isTraceHttpError();
this.markErrorHttpError = config.isMarkErrorHttpError();
}

@Override
Expand Down Expand Up @@ -63,7 +65,7 @@ public void afterTrace(AsyncContext asyncContext, Trace trace, SpanEventRecorder
recorder.recordServiceType(ReactorNettyConstants.REACTOR_NETTY_CLIENT_INTERNAL);
final Throwable argThrowable = ArrayArgumentUtils.getArgument(args, 1, Throwable.class);
if (argThrowable != null) {
recorder.recordException(argThrowable);
recorder.recordException(markErrorHttpError, argThrowable);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ public class ReactorPluginConfig {
private final boolean traceTimeout;
private final boolean traceSubscribe;
private final boolean markErrorRetry;
private final boolean markErrorOnError;

public ReactorPluginConfig(ProfilerConfig config) {
Objects.requireNonNull(config, "config");

// plugin
this.enable = config.readBoolean("profiler.reactor.enable", true);
this.traceOnError = config.readBoolean("profiler.reactor.trace.onError", false);
this.markErrorOnError = config.readBoolean("profiler.reactor.mark.error.onError", false);
this.tracePublishOn = config.readBoolean("profiler.reactor.trace.publishOn", true);
this.traceSubscribeOn = config.readBoolean("profiler.reactor.trace.subscribeOn", true);
this.traceDelay = config.readBoolean("profiler.reactor.trace.delay", true);
Expand Down Expand Up @@ -94,6 +96,10 @@ public boolean isMarkErrorRetry() {
return markErrorRetry;
}

public boolean isMarkErrorOnError() {
return markErrorOnError;
}

@Override
public String toString() {
return "ReactorPluginConfig{" +
Expand All @@ -106,6 +112,8 @@ public String toString() {
", traceRetry=" + traceRetry +
", traceTimeout=" + traceTimeout +
", traceSubscribe=" + traceSubscribe +
", markErrorRetry=" + markErrorRetry +
", markErrorOnError=" + markErrorOnError +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
public class OnErrorSubscriberInterceptor extends AsyncContextSpanEventSimpleAroundInterceptor {

private final boolean traceOnError;
private final boolean markErrorOnError;

public OnErrorSubscriberInterceptor(TraceContext traceContext, MethodDescriptor methodDescriptor) {
super(traceContext, methodDescriptor);
final ReactorPluginConfig config = new ReactorPluginConfig(traceContext.getProfilerConfig());
this.traceOnError = config.isTraceOnError();
this.markErrorOnError = config.isMarkErrorOnError();
}

// AsyncContext must exist in Target for tracking.
Expand Down Expand Up @@ -63,7 +65,7 @@ public void afterTrace(AsyncContext asyncContext, Trace trace, SpanEventRecorder
recorder.recordApi(methodDescriptor);
final Throwable argThrowable = ArrayArgumentUtils.getArgument(args, 0, Throwable.class);
if (argThrowable != null) {
recorder.recordException(argThrowable);
recorder.recordException(markErrorOnError, argThrowable);
}
}
}
Expand Down

0 comments on commit 4b7a556

Please sign in to comment.