Skip to content

Commit

Permalink
add profiler config to enable/disable export
Browse files Browse the repository at this point in the history
  • Loading branch information
yjqg6666 committed May 19, 2020
1 parent a6899c5 commit d3df928
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class ServletRequestListenerInterceptorHelper<T> {
private PLogger logger = PLoggerFactory.getLogger(this.getClass());
private final boolean isDebug = logger.isDebugEnabled();
private final boolean isTrace = logger.isTraceEnabled();
private final boolean exportTraceInfo;
private static final String CONFIG_KEY_EXPORT_TRACE = "profiler.export.trace.info";

private final TraceContext traceContext;
private final ServiceType serviceType;
Expand Down Expand Up @@ -82,6 +84,7 @@ public ServletRequestListenerInterceptorHelper(final ServiceType serviceType, fi
this.httpStatusCodeRecorder = new HttpStatusCodeRecorder(traceContext.getProfilerConfig().getHttpStatusCodeErrors());

this.traceContext.cacheApi(SERVLET_SYNC_METHOD_DESCRIPTOR);
this.exportTraceInfo = this.traceContext.getProfilerConfig().readBoolean(CONFIG_KEY_EXPORT_TRACE, false);
}

private <T> Filter<T> defaultFilter(Filter<T> excludeUrlFilter) {
Expand Down Expand Up @@ -109,9 +112,11 @@ public void initialized(T request, final ServiceType serviceType, final MethodDe
return;
}

TraceId traceId = trace.getTraceId();
if (traceId != null) {
TraceInfoExportHelper.exportTraceInfo(request, traceId.getTransactionId(), traceId.getSpanId());
if (exportTraceInfo) {
TraceId traceId = trace.getTraceId();
if (traceId != null) {
TraceInfoExportHelper.exportTraceInfo(request, traceId.getTransactionId(), traceId.getSpanId());
}
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(serviceType);
Expand Down Expand Up @@ -151,7 +156,9 @@ public void destroyed(T request, final Throwable throwable, final int statusCode
}

// clear trace info which is put in initialized method
TraceInfoExportHelper.clearExportedTraceInfo(request);
if (exportTraceInfo) {
TraceInfoExportHelper.clearExportedTraceInfo(request);
}

// TODO STATDISABLE this logic was added to disable statistics tracing
if (!trace.canSampled()) {
Expand Down

0 comments on commit d3df928

Please sign in to comment.