use of com.navercorp.pinpoint.profiler.context.Span in project pinpoint by naver.
the class SpanThriftMessageConverterTest method buildTSpan.
@Test
public void buildTSpan() {
final Span span = newSpan();
span.setStartTime(System.currentTimeMillis());
span.setElapsedTime(RandomExUtils.nextInt(0, 100));
span.setAcceptorHost("acceptorHost");
span.setExceptionInfo(new IntStringValue(RandomExUtils.nextInt(0, 100), "error"));
span.setApiId(RandomExUtils.nextInt(0, 100));
span.setServiceType((short) RandomExUtils.nextInt(0, 100));
span.setRemoteAddr("remoteAddr");
span.setParentApplicationName("pApp");
span.setParentApplicationType((short) RandomExUtils.nextInt(0, 100));
final TraceRoot traceRoot = span.getTraceRoot();
Shared shared = traceRoot.getShared();
shared.setEndPoint("endPoint");
shared.setRpcName("rpcName");
shared.setLoggingInfo((byte) RandomExUtils.nextInt(0, 10));
shared.maskErrorCode(RandomExUtils.nextInt(0, 100));
shared.setStatusCode(RandomExUtils.nextInt(0, 100));
span.addAnnotation(Annotations.of(1));
span.setSpanEventList(Collections.singletonList(new SpanEvent()));
final TSpan tSpan = messageConverter.buildTSpan(span);
Assert.assertEquals(span.getStartTime(), tSpan.getStartTime());
Assert.assertEquals(span.getElapsedTime(), tSpan.getElapsed());
Assert.assertEquals(span.getAcceptorHost(), tSpan.getAcceptorHost());
Assert.assertEquals(span.getExceptionInfo().getIntValue(), tSpan.getExceptionInfo().getIntValue());
Assert.assertEquals(span.getExceptionInfo().getStringValue(), tSpan.getExceptionInfo().getStringValue());
Assert.assertEquals(span.getApiId(), tSpan.getApiId());
Assert.assertEquals(span.getServiceType(), tSpan.getServiceType());
Assert.assertEquals(span.getRemoteAddr(), tSpan.getRemoteAddr());
Assert.assertEquals(span.getParentApplicationName(), tSpan.getParentApplicationName());
Assert.assertEquals(span.getParentApplicationType(), tSpan.getParentApplicationType());
Assert.assertEquals(traceRoot.getTraceId().getSpanId(), tSpan.getSpanId());
Assert.assertEquals(traceRoot.getShared().getEndPoint(), tSpan.getEndPoint());
Assert.assertEquals(traceRoot.getShared().getRpcName(), tSpan.getRpc());
Assert.assertEquals(traceRoot.getShared().getLoggingInfo(), tSpan.getLoggingTransactionInfo());
Assert.assertEquals(traceRoot.getShared().getErrorCode(), tSpan.getErr());
// TODO
// Assert.assertEquals(traceRoot.getShared().getStatusCode(), );
Assert.assertEquals(span.getAnnotations().size(), tSpan.getAnnotations().size());
Assert.assertEquals(span.getSpanEventList().size(), tSpan.getSpanEventList().size());
}
use of com.navercorp.pinpoint.profiler.context.Span in project pinpoint by naver.
the class GrpcSpanProcessorV2Test method postProcess.
@Test
public void postProcess() {
Span span = newSpan();
SpanEventBuilder factory = new SpanEventBuilder();
factory.addSpanEvent();
factory.addSpanEvent();
factory.addSpanEvent();
span.setSpanEventList(factory.getSpanEventList());
PSpan.Builder builder = PSpan.newBuilder();
for (SpanEvent spanEvent : span.getSpanEventList()) {
PSpanEvent.Builder pSpanEvent = converter.buildPSpanEvent(spanEvent);
builder.addSpanEvent(pSpanEvent);
}
spanProcessorProtoV2.postProcess(span, builder);
PSpan pSpan = builder.build();
List<PSpanEvent> pSpanEventList = pSpan.getSpanEventList();
List<SpanEvent> spanEventList = span.getSpanEventList();
long keyStartTime = span.getStartTime();
for (int i = 0; i < pSpanEventList.size(); i++) {
PSpanEvent pSpanEvent = pSpanEventList.get(i);
SpanEvent next = spanEventList.get(i);
long startTime = keyStartTime + pSpanEvent.getStartElapsed();
Assert.assertEquals(startTime, next.getStartTime());
keyStartTime = startTime;
}
}
use of com.navercorp.pinpoint.profiler.context.Span in project pinpoint by naver.
the class PluginVerifierExternalAdaptor method getServiceTypeCode.
private short getServiceTypeCode(SpanType spanType) {
if (spanType instanceof Span) {
final Span span = (Span) spanType;
return span.getServiceType();
}
if (spanType instanceof SpanChunk) {
final SpanChunk spanChunk = (SpanChunk) spanType;
List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
if (spanEventList.size() != 1) {
throw new IllegalStateException("unexpected spanEventList.size() !=1");
}
SpanEvent spanEvent = spanEventList.get(0);
return spanEvent.getServiceType();
}
return -1;
}
use of com.navercorp.pinpoint.profiler.context.Span in project pinpoint by naver.
the class BasePinpointTest method getCurrentRootSpans.
protected List<Span> getCurrentRootSpans() {
List<Span> rootSpans = new ArrayList<>();
for (Object value : this.tBaseRecorder) {
if (value instanceof Span) {
Span span = (Span) value;
rootSpans.add(span);
}
}
return rootSpans;
}
use of com.navercorp.pinpoint.profiler.context.Span in project pinpoint by naver.
the class ApplicationContextHandler method getExecutedMethod.
public List<String> getExecutedMethod() {
List<String> list = new ArrayList<>();
for (SpanType item : orderedSpanRecorder) {
if (item instanceof Span) {
Span span = (Span) item;
List<SpanEvent> spanEventList = span.getSpanEventList();
addApiDescription(list, spanEventList);
} else if (item instanceof SpanChunk) {
SpanChunk spanChunk = (SpanChunk) item;
List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
addApiDescription(list, spanEventList);
}
}
return list;
}
Aggregations