Search in sources :

Example 1 with DefaultSpanRecorder

use of com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder in project pinpoint by naver.

the class ActiveTrace method getEntryPoint.

public String getEntryPoint() {
    if (!trace.canSampled()) {
        return null;
    }
    SpanRecorder spanRecorder = trace.getSpanRecorder();
    if (!(spanRecorder instanceof DefaultSpanRecorder)) {
        return null;
    }
    Span span = ((DefaultSpanRecorder) spanRecorder).getSpan();
    if (span == null) {
        return null;
    }
    return span.getRpc();
}
Also used : SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) DefaultSpanRecorder(com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder) DefaultSpanRecorder(com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder) Span(com.navercorp.pinpoint.profiler.context.Span)

Example 2 with DefaultSpanRecorder

use of com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder 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 DefaultSpanRecorder

use of com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder 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 DefaultSpanRecorder

use of com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder 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)

Aggregations

SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)4 DefaultSpanRecorder (com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder)4 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3 WrappedSpanEventRecorder (com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder)3 Storage (com.navercorp.pinpoint.profiler.context.storage.Storage)3 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)2 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)2 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)2 Test (org.junit.Test)2 Span (com.navercorp.pinpoint.profiler.context.Span)1