diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/DefaultExceptionRecorderFactory.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/DefaultExceptionRecorderFactory.java index b233f20aa0af..5f049f322489 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/DefaultExceptionRecorderFactory.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/DefaultExceptionRecorderFactory.java @@ -41,7 +41,7 @@ public DefaultExceptionRecorderFactory(ExceptionChainSampler exceptionChainSampl } @Override - public ExceptionRecorder newService(TraceRoot traceRoot) { + public ExceptionRecorder newRecorder(TraceRoot traceRoot) { Objects.requireNonNull(traceRoot, "traceRoot"); ExceptionContext exceptionContext = this.exceptionContextFactory.newExceptionContext(traceRoot); return new DefaultExceptionRecorder(exceptionChainSampler, exceptionWrapperFactory, exceptionContext); diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/DisabledExceptionRecorderFactory.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/DisabledExceptionRecorderFactory.java index 614462ebda39..6ca2c762b387 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/DisabledExceptionRecorderFactory.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/DisabledExceptionRecorderFactory.java @@ -28,7 +28,7 @@ public DisabledExceptionRecorderFactory() { } @Override - public ExceptionRecorder newService(TraceRoot traceRoot) { + public ExceptionRecorder newRecorder(TraceRoot traceRoot) { return DisabledExceptionRecorder.INSTANCE; } } diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/ExceptionRecorderFactory.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/ExceptionRecorderFactory.java index bdf4c21e63f1..4eb4a47bd297 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/ExceptionRecorderFactory.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/ExceptionRecorderFactory.java @@ -22,5 +22,5 @@ */ public interface ExceptionRecorderFactory { - ExceptionRecorder newService(TraceRoot traceRoot); + ExceptionRecorder newRecorder(TraceRoot traceRoot); } diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/ExceptionRecordingState.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/ExceptionRecordingState.java index d5e5a2724fc3..c01d27528782 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/ExceptionRecordingState.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/ExceptionRecordingState.java @@ -20,6 +20,7 @@ import com.navercorp.pinpoint.profiler.context.exception.model.ExceptionWrapperFactory; import com.navercorp.pinpoint.profiler.context.exception.sampler.ExceptionChainSampler; +import java.util.Collections; import java.util.List; /** @@ -43,7 +44,7 @@ public void cleanUp(ExceptionContext context) { CONTINUED { @Override public List toWrappers(ExceptionContext context, ExceptionWrapperFactory factory) { - return null; + return Collections.emptyList(); } @Override @@ -56,7 +57,7 @@ public void cleanUp(ExceptionContext context) { public List toWrappers( ExceptionContext context, ExceptionWrapperFactory factory ) { - return null; + return Collections.emptyList(); } @Override @@ -120,7 +121,6 @@ public void pushThenUpdate( this.update(context, current, currentStartTime, samplingState); } - private void push( ExceptionContext context, ExceptionChainSampler.SamplingState samplingState, @@ -136,7 +136,6 @@ private void push( } } - public void update( ExceptionContext context, Throwable current, diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionContext.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionContext.java index b6e402197fea..712c5a1e872c 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionContext.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionContext.java @@ -28,20 +28,19 @@ */ public class DisabledExceptionContext implements ExceptionContext { - public static final DisabledExceptionContext INSTANCE = new DisabledExceptionContext(); - @Override public void store(List wrappers) { - + // do nothing } @Override public void flush() { - + // do nothing } @Override public void update(Throwable throwable, long startTime, ExceptionChainSampler.SamplingState samplingState) { + // do nothing } @Override @@ -51,6 +50,7 @@ public ExceptionRecordingState stateOf(Throwable throwable) { @Override public void cleanContext() { + // do nothing } @Override diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionContextFactory.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionContextFactory.java index e06e89cf06ce..2c6bf7b3a035 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionContextFactory.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionContextFactory.java @@ -28,6 +28,6 @@ public class DisabledExceptionContextFactory implements ExceptionContextFactory @Override public ExceptionContext newExceptionContext(TraceRoot traceRoot) { - return DisabledExceptionContext.INSTANCE; + return new DisabledExceptionContext(); } } diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionRecorder.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionRecorder.java index a653b7b37a72..1b491601317d 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionRecorder.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/disabled/DisabledExceptionRecorder.java @@ -27,11 +27,11 @@ public class DisabledExceptionRecorder implements ExceptionRecorder { @Override public void recordException(SpanEvent spanEvent, Throwable throwable) { - + // do nothing } @Override public void close() { - + // do nothing } } diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/model/ExceptionMetaData.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/model/ExceptionMetaData.java index 190ed31a4576..d106c27e7bae 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/model/ExceptionMetaData.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/model/ExceptionMetaData.java @@ -55,7 +55,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return exceptionWrappers != null ? exceptionWrappers.hashCode() : 0; + return exceptionWrappers.hashCode(); } @Override diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/model/ExceptionWrapperFactory.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/model/ExceptionWrapperFactory.java index b42df96d33be..c3f51b99c076 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/model/ExceptionWrapperFactory.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/model/ExceptionWrapperFactory.java @@ -16,6 +16,7 @@ package com.navercorp.pinpoint.profiler.context.exception.model; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -32,7 +33,7 @@ public ExceptionWrapperFactory(int maxDepth, int maxErrorMessageLength) { public List newExceptionWrappers(ExceptionContext context) { if (context == null) { - return null; + return Collections.emptyList(); } return traverseAndWrap( context.getContextValue(), context.getExceptionId() @@ -46,13 +47,12 @@ private List traverseAndWrap(ExceptionContextValue topExceptio for (ExceptionContextValue curr = topExceptionContextValue; curr.getPrevious() != null; curr = curr.getPrevious()) { - int newDepth = addAllExceptionWrappers( + depth = addAllExceptionWrappers( exceptionWrappers, curr.getThrowable(), curr.getPrevious().getThrowable(), curr.getStartTime(), exceptionId, depth ); - depth = newDepth; } return exceptionWrappers; diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/sampler/ExceptionChainSampler.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/sampler/ExceptionChainSampler.java index a764873d9731..4d38a666a6c5 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/sampler/ExceptionChainSampler.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/sampler/ExceptionChainSampler.java @@ -28,11 +28,9 @@ public class ExceptionChainSampler { public static final long INITIAL_EXCEPTION_ID = 1L; private final RateLimiter rateLimiter; - private final AtomicLong exceptionChainId = new AtomicLong(INITIAL_EXCEPTION_ID); - - public final static SamplingState DISABLED = new SamplingState() { + public static final SamplingState DISABLED = new SamplingState() { @Override public boolean isSampling() { return false; diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/storage/BufferedExceptionStorage.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/storage/BufferedExceptionStorage.java index 8f30a90f9067..7042c96f6cd0 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/storage/BufferedExceptionStorage.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/exception/storage/BufferedExceptionStorage.java @@ -88,9 +88,10 @@ private void sendExceptionMetaData(List exceptionWrappers) { @Override public String toString() { - return "ExceptionTraceStorage{" + + return "BufferedExceptionStorage{" + "buffer=" + buffer + ", dataSender=" + dataSender + + ", factory=" + factory + '}'; } } diff --git a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java index 0904781059c3..6030987c69ef 100644 --- a/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java +++ b/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java @@ -65,7 +65,7 @@ public DefaultRecorderFactory(Provider asyncContextFactoryP public SpanRecorder newSpanRecorder(Span span) { Objects.requireNonNull(span, "span"); - ExceptionRecorder exceptionRecorder = exceptionRecorderFactory.newService(span.getTraceRoot()); + ExceptionRecorder exceptionRecorder = exceptionRecorderFactory.newRecorder(span.getTraceRoot()); return new DefaultSpanRecorder(span, stringMetaDataService, sqlMetaDataService, errorHandler, exceptionRecorder); } @@ -88,7 +88,7 @@ public WrappedSpanEventRecorder newWrappedSpanEventRecorder(TraceRoot traceRoot) Objects.requireNonNull(traceRoot, "traceRoot"); final AsyncContextFactory asyncContextFactory = asyncContextFactoryProvider.get(); - ExceptionRecorder exceptionRecorder = exceptionRecorderFactory.newService(traceRoot); + ExceptionRecorder exceptionRecorder = exceptionRecorderFactory.newRecorder(traceRoot); return new WrappedSpanEventRecorder(traceRoot, asyncContextFactory, stringMetaDataService, sqlMetaDataService, errorHandler, exceptionRecorder, sqlCountService); @@ -100,7 +100,7 @@ public WrappedSpanEventRecorder newWrappedSpanEventRecorder(TraceRoot traceRoot, Objects.requireNonNull(asyncState, "asyncState"); final AsyncContextFactory asyncContextFactory = asyncContextFactoryProvider.get(); - ExceptionRecorder exceptionRecorder = exceptionRecorderFactory.newService(traceRoot); + ExceptionRecorder exceptionRecorder = exceptionRecorderFactory.newRecorder(traceRoot); return new WrappedSpanEventRecorder(traceRoot, asyncContextFactory, asyncState, stringMetaDataService, sqlMetaDataService, errorHandler, exceptionRecorder, sqlCountService); @@ -111,7 +111,7 @@ public WrappedSpanEventRecorder newChildTraceSpanEventRecorder(TraceRoot traceRo Objects.requireNonNull(traceRoot, "traceRoot"); final AsyncContextFactory asyncContextFactory = asyncContextFactoryProvider.get(); - ExceptionRecorder exceptionRecorder = exceptionRecorderFactory.newService(traceRoot); + ExceptionRecorder exceptionRecorder = exceptionRecorderFactory.newRecorder(traceRoot); return new ChildTraceSpanEventRecorder(traceRoot, asyncContextFactory, stringMetaDataService, sqlMetaDataService, errorHandler, exceptionRecorder, sqlCountService); diff --git a/agent-module/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java b/agent-module/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java index 58de56d8105b..1cf5c63c8a8e 100644 --- a/agent-module/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java +++ b/agent-module/profiler/src/test/java/com/navercorp/pinpoint/profiler/context/TraceTest.java @@ -80,7 +80,6 @@ public void trace() { SpanRecorder spanRecorder = new DefaultSpanRecorder(span, stringMetaDataService, sqlMetaDataService, errorHandler, exceptionRecorder); WrappedSpanEventRecorder wrappedSpanEventRecorder = new WrappedSpanEventRecorder(traceRoot, asyncContextFactory, stringMetaDataService, sqlMetaDataService, errorHandler, exceptionRecorder, sqlCountService); - ExceptionContext exceptionContext = DisabledExceptionContext.INSTANCE; Storage storage = mock(Storage.class); @@ -111,7 +110,6 @@ public void popEventTest() { SpanRecorder spanRecorder = new DefaultSpanRecorder(span, stringMetaDataService, sqlMetaDataService, errorHandler, exceptionRecorder); WrappedSpanEventRecorder wrappedSpanEventRecorder = new WrappedSpanEventRecorder(traceRoot, asyncContextFactory, stringMetaDataService, sqlMetaDataService, errorHandler, exceptionRecorder, sqlCountService); - ExceptionContext exceptionContext = DisabledExceptionContext.INSTANCE; Storage storage = mock(Storage.class); diff --git a/exceptiontrace/exceptiontrace-collector/src/main/java/com/navercorp/pinpoint/exceptiontrace/collector/service/PinotExceptionTraceService.java b/exceptiontrace/exceptiontrace-collector/src/main/java/com/navercorp/pinpoint/exceptiontrace/collector/service/PinotExceptionMetaDataService.java similarity index 97% rename from exceptiontrace/exceptiontrace-collector/src/main/java/com/navercorp/pinpoint/exceptiontrace/collector/service/PinotExceptionTraceService.java rename to exceptiontrace/exceptiontrace-collector/src/main/java/com/navercorp/pinpoint/exceptiontrace/collector/service/PinotExceptionMetaDataService.java index 8aed9c8e8704..ece33e1c7ff9 100644 --- a/exceptiontrace/exceptiontrace-collector/src/main/java/com/navercorp/pinpoint/exceptiontrace/collector/service/PinotExceptionTraceService.java +++ b/exceptiontrace/exceptiontrace-collector/src/main/java/com/navercorp/pinpoint/exceptiontrace/collector/service/PinotExceptionMetaDataService.java @@ -42,13 +42,13 @@ @Service @ConditionalOnProperty(name = "pinpoint.modules.collector.exceptiontrace.enabled", havingValue = "true") @Validated -public class PinotExceptionTraceService implements ExceptionMetaDataService { +public class PinotExceptionMetaDataService implements ExceptionMetaDataService { private final ExceptionTraceDao exceptionTraceDao; private final ServiceTypeRegistryService registry; private final TenantProvider tenantProvider; - public PinotExceptionTraceService( + public PinotExceptionMetaDataService( ExceptionTraceDao exceptionTraceDao, ServiceTypeRegistryService registry, TenantProvider tenantProvider