Skip to content

Commit

Permalink
[pinpoint-apm#9631] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
intr3p1d committed May 21, 2024
1 parent df454c5 commit e561d31
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public DisabledExceptionRecorderFactory() {
}

@Override
public ExceptionRecorder newService(TraceRoot traceRoot) {
public ExceptionRecorder newRecorder(TraceRoot traceRoot) {
return DisabledExceptionRecorder.INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
*/
public interface ExceptionRecorderFactory {

ExceptionRecorder newService(TraceRoot traceRoot);
ExceptionRecorder newRecorder(TraceRoot traceRoot);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -43,7 +44,7 @@ public void cleanUp(ExceptionContext context) {
CONTINUED {
@Override
public List<ExceptionWrapper> toWrappers(ExceptionContext context, ExceptionWrapperFactory factory) {
return null;
return Collections.emptyList();
}

@Override
Expand All @@ -56,7 +57,7 @@ public void cleanUp(ExceptionContext context) {
public List<ExceptionWrapper> toWrappers(
ExceptionContext context, ExceptionWrapperFactory factory
) {
return null;
return Collections.emptyList();
}

@Override
Expand Down Expand Up @@ -120,7 +121,6 @@ public void pushThenUpdate(
this.update(context, current, currentStartTime, samplingState);
}


private void push(
ExceptionContext context,
ExceptionChainSampler.SamplingState samplingState,
Expand All @@ -136,7 +136,6 @@ private void push(
}
}


public void update(
ExceptionContext context,
Throwable current,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@
*/
public class DisabledExceptionContext implements ExceptionContext {

public static final DisabledExceptionContext INSTANCE = new DisabledExceptionContext();

@Override
public void store(List<ExceptionWrapper> wrappers) {

// do nothing
}

@Override
public void flush() {

// do nothing
}

@Override
public void update(Throwable throwable, long startTime, ExceptionChainSampler.SamplingState samplingState) {
// do nothing
}

@Override
Expand All @@ -51,6 +50,7 @@ public ExceptionRecordingState stateOf(Throwable throwable) {

@Override
public void cleanContext() {
// do nothing
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public class DisabledExceptionContextFactory implements ExceptionContextFactory

@Override
public ExceptionContext newExceptionContext(TraceRoot traceRoot) {
return DisabledExceptionContext.INSTANCE;
return new DisabledExceptionContext();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return exceptionWrappers != null ? exceptionWrappers.hashCode() : 0;
return exceptionWrappers.hashCode();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.navercorp.pinpoint.profiler.context.exception.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
Expand All @@ -32,7 +33,7 @@ public ExceptionWrapperFactory(int maxDepth, int maxErrorMessageLength) {

public List<ExceptionWrapper> newExceptionWrappers(ExceptionContext context) {
if (context == null) {
return null;
return Collections.emptyList();
}
return traverseAndWrap(
context.getContextValue(), context.getExceptionId()
Expand All @@ -46,13 +47,12 @@ private List<ExceptionWrapper> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ private void sendExceptionMetaData(List<ExceptionWrapper> exceptionWrappers) {

@Override
public String toString() {
return "ExceptionTraceStorage{" +
return "BufferedExceptionStorage{" +
"buffer=" + buffer +
", dataSender=" + dataSender +
", factory=" + factory +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public DefaultRecorderFactory(Provider<AsyncContextFactory> 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);
}

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e561d31

Please sign in to comment.