use of com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder in project pinpoint by naver.
the class DefaultTrace method wrappedSpanEventRecorder.
private SpanEventRecorder wrappedSpanEventRecorder(SpanEvent spanEvent) {
final WrappedSpanEventRecorder spanEventRecorder = this.spanEventRecorder;
spanEventRecorder.setWrapped(spanEvent);
return spanEventRecorder;
}
use of com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder in project pinpoint by naver.
the class DefaultTraceTest method newTrace.
private Trace newTrace(final int maxCallStackDepth) {
when(traceRoot.getShared()).thenReturn(shared);
TraceId traceId = new DefaultTraceId(agentId, agentStartTime, 0);
when(traceRoot.getTraceId()).thenReturn(traceId);
CallStackFactory<SpanEvent> callStackFactory = new CallStackFactoryV1(maxCallStackDepth, -1);
CallStack<SpanEvent> callStack = callStackFactory.newCallStack();
SpanFactory spanFactory = new DefaultSpanFactory();
Storage storage = mock(Storage.class);
final Span span = spanFactory.newSpan(traceRoot);
final boolean root = span.getTraceRoot().getTraceId().isRoot();
final SpanRecorder spanRecorder = new DefaultSpanRecorder(span, root, true, stringMetaDataService, sqlMetaDataService, errorHandler);
final WrappedSpanEventRecorder wrappedSpanEventRecorder = new WrappedSpanEventRecorder(traceRoot, asyncContextFactory, stringMetaDataService, sqlMetaDataService, errorHandler);
return new DefaultTrace(span, callStack, storage, true, spanRecorder, wrappedSpanEventRecorder, ActiveTraceHandle.EMPTY_HANDLE);
}
use of com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder in project pinpoint by naver.
the class TraceTest method trace.
@Test
public void trace() {
final TraceId traceId = new DefaultTraceId(agentId, agentStartTime, 1);
final TraceRoot traceRoot = new DefaultTraceRoot(traceId, agentId, traceStartTime, 0);
final CallStack<SpanEvent> callStack = newCallStack();
final Span span = newSpan(traceRoot);
boolean root = span.getTraceRoot().getTraceId().isRoot();
SpanRecorder spanRecorder = new DefaultSpanRecorder(span, root, true, stringMetaDataService, sqlMetaDataService, errorHandler);
WrappedSpanEventRecorder wrappedSpanEventRecorder = new WrappedSpanEventRecorder(traceRoot, asyncContextFactory, stringMetaDataService, sqlMetaDataService, errorHandler);
AsyncContextFactory asyncContextFactory = mock(AsyncContextFactory.class);
Storage storage = mock(Storage.class);
Trace trace = new DefaultTrace(span, callStack, storage, true, spanRecorder, wrappedSpanEventRecorder, ActiveTraceHandle.EMPTY_HANDLE);
trace.traceBlockBegin();
// get data form db
getDataFromDB(trace);
// response to client
trace.traceBlockEnd();
verify(storage, times(2)).store(Mockito.any(SpanEvent.class));
verify(storage, never()).store(Mockito.any(Span.class));
}
use of com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder in project pinpoint by naver.
the class TraceTest method popEventTest.
@Test
public void popEventTest() {
final TraceId traceId = new DefaultTraceId(agentId, agentStartTime, 1);
final TraceRoot traceRoot = new DefaultTraceRoot(traceId, agentId, traceStartTime, 0);
final CallStack<SpanEvent> callStack = newCallStack();
final Span span = newSpan(traceRoot);
final boolean root = span.getTraceRoot().getTraceId().isRoot();
SpanRecorder spanRecorder = new DefaultSpanRecorder(span, root, true, stringMetaDataService, sqlMetaDataService, errorHandler);
WrappedSpanEventRecorder wrappedSpanEventRecorder = new WrappedSpanEventRecorder(traceRoot, asyncContextFactory, stringMetaDataService, sqlMetaDataService, errorHandler);
AsyncContextFactory asyncContextFactory = mock(AsyncContextFactory.class);
Storage storage = mock(Storage.class);
Trace trace = new DefaultTrace(span, callStack, storage, true, spanRecorder, wrappedSpanEventRecorder, ActiveTraceHandle.EMPTY_HANDLE);
trace.close();
verify(storage, never()).store(Mockito.any(SpanEvent.class));
verify(storage).store(Mockito.any(Span.class));
}
use of com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder in project pinpoint by naver.
the class DefaultBaseTraceFactory method continueAsyncTraceObject.
// entry point async trace.
@InterfaceAudience.LimitedPrivate("vert.x")
@Override
public Trace continueAsyncTraceObject(final TraceId traceId) {
final TraceSampler.State state = traceSampler.isContinueSampled();
final boolean sampling = state.isSampled();
if (sampling) {
final TraceRoot traceRoot = traceRootFactory.continueTraceRoot(traceId, state.nextId());
final Span span = spanFactory.newSpan(traceRoot);
final SpanChunkFactory spanChunkFactory = new DefaultSpanChunkFactory(traceRoot);
final Storage storage = storageFactory.createStorage(spanChunkFactory);
final CallStack<SpanEvent> callStack = callStackFactory.newCallStack();
final ActiveTraceHandle handle = registerActiveTrace(traceRoot);
final SpanAsyncStateListener asyncStateListener = new SpanAsyncStateListener(span, storageFactory);
final AsyncState asyncState = new ListenableAsyncState(asyncStateListener, handle);
final SpanRecorder spanRecorder = recorderFactory.newSpanRecorder(span, traceId.isRoot(), sampling);
final WrappedSpanEventRecorder wrappedSpanEventRecorder = recorderFactory.newWrappedSpanEventRecorder(traceRoot, asyncState);
final DefaultTrace trace = new DefaultTrace(span, callStack, storage, sampling, spanRecorder, wrappedSpanEventRecorder, ActiveTraceHandle.EMPTY_HANDLE);
final AsyncTrace asyncTrace = new AsyncTrace(traceRoot, trace, asyncState);
return asyncTrace;
} else {
return newDisableTrace(state.nextId());
}
}
Aggregations