Search in sources :

Example 1 with WrappedSpanEventRecorder

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;
}
Also used : WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder)

Example 2 with WrappedSpanEventRecorder

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);
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) DefaultSpanRecorder(com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultSpanRecorder(com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder)

Example 3 with WrappedSpanEventRecorder

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));
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) DefaultSpanRecorder(com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) DefaultSpanRecorder(com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder) Test(org.junit.Test)

Example 4 with WrappedSpanEventRecorder

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));
}
Also used : DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) DefaultSpanRecorder(com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) DefaultSpanRecorder(com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder) Test(org.junit.Test)

Example 5 with WrappedSpanEventRecorder

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());
    }
}
Also used : TraceSampler(com.navercorp.pinpoint.bootstrap.sampler.TraceSampler) ActiveTraceHandle(com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle) ListenableAsyncState(com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState) AsyncState(com.navercorp.pinpoint.bootstrap.context.AsyncState) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) ListenableAsyncState(com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot)

Aggregations

WrappedSpanEventRecorder (com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder)9 SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)8 Storage (com.navercorp.pinpoint.profiler.context.storage.Storage)8 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)6 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)5 TraceSampler (com.navercorp.pinpoint.bootstrap.sampler.TraceSampler)4 ActiveTraceHandle (com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle)4 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3 DefaultSpanRecorder (com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder)3 AsyncState (com.navercorp.pinpoint.bootstrap.context.AsyncState)2 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)2 ListenableAsyncState (com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState)2 Test (org.junit.Test)2