Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#10371] Update child trace end point guard #10373

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import java.util.Objects;

public class AsyncChildTrace implements Trace {
public class ChildTrace implements Trace {

private static final int ASYNC_BEGIN_STACK_ID = 1001;

Expand All @@ -56,10 +56,10 @@
private final TraceRoot traceRoot;
private final LocalAsyncId localAsyncId;

public AsyncChildTrace(final TraceRoot traceRoot, CallStack<SpanEvent> callStack, Storage storage,
SpanRecorder spanRecorder, WrappedSpanEventRecorder wrappedSpanEventRecorder,
ExceptionContext exceptionContext,
final LocalAsyncId localAsyncId) {
public ChildTrace(final TraceRoot traceRoot, CallStack<SpanEvent> callStack, Storage storage,
SpanRecorder spanRecorder, WrappedSpanEventRecorder wrappedSpanEventRecorder,
ExceptionContext exceptionContext,
final LocalAsyncId localAsyncId) {

Check warning on line 62 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/ChildTrace.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/ChildTrace.java#L62

Added line #L62 was not covered by tests

this.traceRoot = Objects.requireNonNull(traceRoot, "traceRoot");
this.callStack = Objects.requireNonNull(callStack, "callStack");
Expand Down Expand Up @@ -307,7 +307,7 @@

@Override
public String toString() {
return "AsyncChildTrace{" +
return "ChildTrace{" +

Check warning on line 310 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/ChildTrace.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/ChildTrace.java#L310

Added line #L310 was not covered by tests
"traceRoot=" + getTraceRoot() +
", localAsyncId=" + localAsyncId +
'}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,19 @@
final CallStack<SpanEvent> callStack = callStackFactory.newCallStack();

final SpanRecorder spanRecorder = recorderFactory.newTraceRootSpanRecorder(traceRoot);
final WrappedSpanEventRecorder wrappedSpanEventRecorder = recorderFactory.newWrappedSpanEventRecorder(traceRoot);
final WrappedSpanEventRecorder wrappedSpanEventRecorder = recorderFactory.newChildTraceSpanEventRecorder(traceRoot);

Check warning on line 138 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultBaseTraceFactory.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultBaseTraceFactory.java#L138

Added line #L138 was not covered by tests
final ExceptionContext exceptionContext = exceptionContextFactory.newExceptionContext(traceRoot);

return new AsyncChildTrace(traceRoot, callStack, storage, spanRecorder, wrappedSpanEventRecorder, exceptionContext, localAsyncId);
return new ChildTrace(traceRoot, callStack, storage, spanRecorder, wrappedSpanEventRecorder, exceptionContext, localAsyncId);

Check warning on line 141 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultBaseTraceFactory.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultBaseTraceFactory.java#L141

Added line #L141 was not covered by tests
}

@Override
public Trace continueDisableAsyncContextTraceObject(LocalTraceRoot traceRoot) {
final AsyncState asyncState = newAsyncState(traceRoot, ActiveTraceHandle.EMPTY_HANDLE, ListenableAsyncState.AsyncStateListener.EMPTY);

SpanRecorder spanRecorder = recorderFactory.newDisableSpanRecorder(traceRoot);
SpanEventRecorder spanEventRecorder = recorderFactory.newDisableSpanEventRecorder(traceRoot, asyncState);
return new DisableAsyncChildTrace(traceRoot, spanRecorder, spanEventRecorder);
SpanEventRecorder spanEventRecorder = recorderFactory.newDisableChildTraceSpanEventRecorder(traceRoot, asyncState);
return new DisableChildTrace(traceRoot, spanRecorder, spanEventRecorder);

Check warning on line 150 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultBaseTraceFactory.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultBaseTraceFactory.java#L149-L150

Added lines #L149 - L150 were not covered by tests
}

// entry point async trace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import java.util.Objects;

public class DisableAsyncChildTrace implements Trace {
public class DisableChildTrace implements Trace {
// private static final int ASYNC_BEGIN_STACK_ID = 1001;
public static final String UNSUPPORTED_OPERATION = "disable async child trace";

Expand All @@ -45,7 +45,7 @@
private final SpanRecorder spanRecorder;
private final SpanEventRecorder spanEventRecorder;

public DisableAsyncChildTrace(final LocalTraceRoot traceRoot, SpanRecorder spanRecorder, SpanEventRecorder spanEventRecorder) {
public DisableChildTrace(final LocalTraceRoot traceRoot, SpanRecorder spanRecorder, SpanEventRecorder spanEventRecorder) {
this.traceRoot = Objects.requireNonNull(traceRoot, "traceRoot");
this.spanRecorder = Objects.requireNonNull(spanRecorder, "spanRecorder");
this.spanEventRecorder = Objects.requireNonNull(spanEventRecorder, "spanEventRecorder");
Expand Down Expand Up @@ -172,7 +172,7 @@

@Override
public String toString() {
return "DisableAsyncChildTrace{" +
return "DisableChildTrace{" +

Check warning on line 175 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DisableChildTrace.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DisableChildTrace.java#L175

Added line #L175 was not covered by tests
"traceRoot=" + traceRoot +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2023 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.navercorp.pinpoint.profiler.context.recorder;

import com.navercorp.pinpoint.bootstrap.context.AsyncContext;
import com.navercorp.pinpoint.profiler.context.AsyncContextFactory;
import com.navercorp.pinpoint.profiler.context.errorhandler.IgnoreErrorHandler;
import com.navercorp.pinpoint.profiler.context.exception.ExceptionRecordingService;
import com.navercorp.pinpoint.profiler.context.id.TraceRoot;
import com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService;
import com.navercorp.pinpoint.profiler.metadata.StringMetaDataService;

public class ChildTraceSpanEventRecorder extends WrappedSpanEventRecorder {

public ChildTraceSpanEventRecorder(TraceRoot traceRoot,
AsyncContextFactory asyncContextFactory,
StringMetaDataService stringMetaDataService,
SqlMetaDataService sqlMetaDataService,
IgnoreErrorHandler ignoreErrorHandler,
ExceptionRecordingService exceptionRecordingService) {
super(traceRoot, asyncContextFactory, stringMetaDataService, sqlMetaDataService, ignoreErrorHandler, exceptionRecordingService);
}

Check warning on line 36 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/ChildTraceSpanEventRecorder.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/ChildTraceSpanEventRecorder.java#L35-L36

Added lines #L35 - L36 were not covered by tests

@Override
public AsyncContext recordNextAsyncContext(boolean asyncStateSupport) {
return super.recordNextAsyncContext();

Check warning on line 40 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/ChildTraceSpanEventRecorder.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/ChildTraceSpanEventRecorder.java#L40

Added line #L40 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.navercorp.pinpoint.profiler.context.exception.ExceptionRecordingService;
import com.navercorp.pinpoint.profiler.context.id.LocalTraceRoot;
import com.navercorp.pinpoint.profiler.context.id.TraceRoot;
import com.navercorp.pinpoint.profiler.context.exception.DefaultExceptionRecordingService;
import com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService;
import com.navercorp.pinpoint.profiler.metadata.StringMetaDataService;

Expand Down Expand Up @@ -97,6 +96,15 @@
stringMetaDataService, sqlMetaDataService, errorHandler, exceptionRecordingService);
}

@Override
public WrappedSpanEventRecorder newChildTraceSpanEventRecorder(TraceRoot traceRoot) {
Objects.requireNonNull(traceRoot, "traceRoot");

Check warning on line 101 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java#L101

Added line #L101 was not covered by tests

final AsyncContextFactory asyncContextFactory = asyncContextFactoryProvider.get();
return new ChildTraceSpanEventRecorder(traceRoot, asyncContextFactory,

Check warning on line 104 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java#L103-L104

Added lines #L103 - L104 were not covered by tests
stringMetaDataService, sqlMetaDataService, errorHandler, exceptionRecordingService);
}

@Override
public DisableSpanEventRecorder newDisableSpanEventRecorder(LocalTraceRoot traceRoot, AsyncState asyncState) {
Objects.requireNonNull(traceRoot, "traceRoot");
Expand All @@ -116,4 +124,13 @@
final AsyncContextFactory asyncContextFactory = asyncContextFactoryProvider.get();
return new DisableSpanEventRecorder(traceRoot, asyncContextFactory, asyncState);
}

@Override
public DisableSpanEventRecorder newDisableChildTraceSpanEventRecorder(LocalTraceRoot traceRoot, AsyncState asyncState) {
Objects.requireNonNull(traceRoot, "traceRoot");
Objects.requireNonNull(asyncState, "asyncState");

Check warning on line 131 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java#L130-L131

Added lines #L130 - L131 were not covered by tests

final AsyncContextFactory asyncContextFactory = asyncContextFactoryProvider.get();
return new DisableChildTraceSpanEventRecorder(traceRoot, asyncContextFactory, asyncState);

Check warning on line 134 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java#L133-L134

Added lines #L133 - L134 were not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2023 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.navercorp.pinpoint.profiler.context.recorder;

import com.navercorp.pinpoint.bootstrap.context.AsyncContext;
import com.navercorp.pinpoint.bootstrap.context.AsyncState;
import com.navercorp.pinpoint.profiler.context.AsyncContextFactory;
import com.navercorp.pinpoint.profiler.context.id.LocalTraceRoot;

public class DisableChildTraceSpanEventRecorder extends DisableSpanEventRecorder {

public DisableChildTraceSpanEventRecorder(LocalTraceRoot traceRoot, AsyncContextFactory asyncContextFactory, AsyncState asyncState) {
super(traceRoot, asyncContextFactory, asyncState);
}

Check warning on line 28 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DisableChildTraceSpanEventRecorder.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DisableChildTraceSpanEventRecorder.java#L27-L28

Added lines #L27 - L28 were not covered by tests

@Override
public AsyncContext recordNextAsyncContext(boolean stateful) {
// child trace does not have an async end-point
return super.recordNextAsyncContext();

Check warning on line 33 in profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DisableChildTraceSpanEventRecorder.java

View check run for this annotation

Codecov / codecov/patch

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DisableChildTraceSpanEventRecorder.java#L33

Added line #L33 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ public interface RecorderFactory {

WrappedSpanEventRecorder newWrappedSpanEventRecorder(TraceRoot traceRoot, AsyncState asyncState);

WrappedSpanEventRecorder newChildTraceSpanEventRecorder(TraceRoot traceRoot);

DisableSpanEventRecorder newDisableSpanEventRecorder(LocalTraceRoot traceRoot);

DisableSpanEventRecorder newDisableSpanEventRecorder(LocalTraceRoot traceRoot, AsyncState asyncState);

DisableSpanEventRecorder newDisableChildTraceSpanEventRecorder(LocalTraceRoot traceRoot, AsyncState asyncState);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected AsyncTraceContext newAsyncTraceContext() {
.thenAnswer(new Answer<Trace>() {
@Override
public Trace answer(InvocationOnMock invocationOnMock) {
Trace trace = mock(AsyncChildTrace.class);
Trace trace = mock(ChildTrace.class);
when(trace.canSampled()).thenReturn(true);
return trace;
}
Expand All @@ -48,7 +48,7 @@ public Trace answer(InvocationOnMock invocationOnMock) {
.thenAnswer(new Answer<Trace>() {
@Override
public Trace answer(InvocationOnMock invocationOnMock) {
return mock(DisableAsyncChildTrace.class);
return mock(DisableChildTrace.class);
}
});
when(baseTraceFactoryProvider.get()).thenReturn(baseTraceFactory);
Expand Down Expand Up @@ -76,10 +76,10 @@ public void testAsyncTraceObject() {
Trace enabledTrace = enabledAsyncContext.continueAsyncTraceObject();
Trace disabledTrace = disabledAsyncContext.continueAsyncTraceObject();
assertThat(enabledTrace)
.isInstanceOf(AsyncChildTrace.class)
.isInstanceOf(ChildTrace.class)
.isEqualTo(enabledAsyncContext.currentAsyncTraceObject());
assertThat(disabledTrace)
.isInstanceOf(DisableAsyncChildTrace.class)
.isInstanceOf(DisableChildTrace.class)
.isEqualTo(disabledAsyncContext.currentAsyncTraceObject());


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected AsyncTraceContext newAsyncTraceContext() {
.thenAnswer(new Answer<Trace>() {
@Override
public Trace answer(InvocationOnMock invocationOnMock) {
Trace trace = mock(AsyncChildTrace.class);
Trace trace = mock(ChildTrace.class);
when(trace.canSampled()).thenReturn(true);
return trace;
}
Expand All @@ -39,7 +39,7 @@ public Trace answer(InvocationOnMock invocationOnMock) {
.thenAnswer(new Answer<Trace>() {
@Override
public Trace answer(InvocationOnMock invocationOnMock) {
return mock(DisableAsyncChildTrace.class);
return mock(DisableChildTrace.class);
}
});
when(baseTraceFactoryProvider.get()).thenReturn(baseTraceFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.navercorp.pinpoint.bootstrap.context.SpanRecorder;
import com.navercorp.pinpoint.bootstrap.context.Trace;
import com.navercorp.pinpoint.profiler.context.CloseListener;
import com.navercorp.pinpoint.profiler.context.DisableAsyncChildTrace;
import com.navercorp.pinpoint.profiler.context.DisableChildTrace;
import com.navercorp.pinpoint.profiler.context.DisableTrace;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -77,6 +77,6 @@ private Trace newTrace(LocalTraceRoot traceRoot) {
private Trace newChildTrace(LocalTraceRoot traceRoot) {
SpanRecorder spanRecorder = mock(SpanRecorder.class);
SpanEventRecorder spanEventRecorder = mock(SpanEventRecorder.class);
return new DisableAsyncChildTrace(traceRoot, spanRecorder, spanEventRecorder);
return new DisableChildTrace(traceRoot, spanRecorder, spanEventRecorder);
}
}