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();
}
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);
}
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));
}
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));
}
Aggregations