Skip to content

Commit

Permalink
[pinpoint-apm#10437] Update mark error of spring tx plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jaehong-kim committed Oct 26, 2023
1 parent 091d898 commit c878a9b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions agent/src/main/resources/profiles/local/pinpoint.config
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@ profiler.spring.webmvc.enable=true
# Spring Transaction Management
###########################################################
profiler.spring.tx.enable=true
profiler.spring.tx.mark.error=false

###########################################################
# Reactor
Expand Down
1 change: 1 addition & 0 deletions agent/src/main/resources/profiles/release/pinpoint.config
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,7 @@ profiler.spring.webmvc.enable=true
# Spring Transaction Management
###########################################################
profiler.spring.tx.enable=true
profiler.spring.tx.mark.error=false

###########################################################
# Reactor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,26 @@

public class SpringTxConfig {
private final boolean enabled;
private final boolean markError;

public SpringTxConfig(ProfilerConfig config) {
this.enabled = config.readBoolean("profiler.spring.tx.enable", true);
this.markError = config.readBoolean("profiler.spring.tx.mark.error", false);
}

public boolean isEnabled() {
return enabled;
}

public boolean isMarkError() {
return markError;
}

@Override
public String toString() {
return "SpringTxConfig{" +
"enabled=" + enabled +
", markError=" + markError +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@
import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptorForPlugin;
import com.navercorp.pinpoint.plugin.spring.tx.SpringTxConfig;
import com.navercorp.pinpoint.plugin.spring.tx.SpringTxConstants;

public class ReactiveTransactionSupportInterceptor extends SpanEventSimpleAroundInterceptorForPlugin {

private final boolean markError;

public ReactiveTransactionSupportInterceptor(TraceContext traceContext, MethodDescriptor methodDescriptor) {
super(traceContext, methodDescriptor);
final SpringTxConfig config = new SpringTxConfig(traceContext.getProfilerConfig());
this.markError = config.isMarkError();
}

@Override
Expand All @@ -37,7 +42,7 @@ public void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[]
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) throws Exception {
recorder.recordServiceType(SpringTxConstants.SPRING_TX);
recorder.recordException(throwable);
recorder.recordException(markError, throwable);
recorder.recordApi(methodDescriptor);

if (throwable != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,27 @@
import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptorForPlugin;
import com.navercorp.pinpoint.plugin.spring.tx.SpringTxConfig;
import com.navercorp.pinpoint.plugin.spring.tx.SpringTxConstants;

public class TransactionAspectSupportInterceptor extends SpanEventSimpleAroundInterceptorForPlugin {

private final boolean markError;

public TransactionAspectSupportInterceptor(TraceContext traceContext, MethodDescriptor methodDescriptor) {
super(traceContext, methodDescriptor);
final SpringTxConfig config = new SpringTxConfig(traceContext.getProfilerConfig());
this.markError = config.isMarkError();
}

@Override
public void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) throws Exception {

}

@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) throws Exception {
recorder.recordServiceType(SpringTxConstants.SPRING_TX);
recorder.recordException(throwable);
recorder.recordException(markError, throwable);
recorder.recordApi(methodDescriptor);
}
}

0 comments on commit c878a9b

Please sign in to comment.