use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.
the class GrpcSpanMessageConverter method buildPSpanEvent.
@VisibleForTesting
public PSpanEvent.Builder buildPSpanEvent(SpanEvent spanEvent) {
final PSpanEvent.Builder pSpanEvent = getSpanEventBuilder();
// tSpanEvent.setStartElapsed(spanEvent.getStartElapsed());
if (spanEvent.getElapsedTime() != 0) {
pSpanEvent.setEndElapsed(spanEvent.getElapsedTime());
}
pSpanEvent.setSequence(spanEvent.getSequence());
// tSpanEvent.setRpc(spanEvent.getRpc());
pSpanEvent.setServiceType(spanEvent.getServiceType());
// tSpanEvent.setAnnotations();
if (spanEvent.getDepth() != -1) {
pSpanEvent.setDepth(spanEvent.getDepth());
}
pSpanEvent.setApiId(spanEvent.getApiId());
final IntStringValue exceptionInfo = spanEvent.getExceptionInfo();
if (exceptionInfo != null) {
PIntStringValue pIntStringValue = buildPIntStringValue(exceptionInfo);
pSpanEvent.setExceptionInfo(pIntStringValue);
}
final PNextEvent nextEvent = buildNextEvent(spanEvent);
if (nextEvent != null) {
pSpanEvent.setNextEvent(nextEvent);
}
final AsyncId asyncIdObject = spanEvent.getAsyncIdObject();
if (asyncIdObject != null) {
pSpanEvent.setAsyncEvent(asyncIdObject.getAsyncId());
}
final List<Annotation<?>> annotations = spanEvent.getAnnotations();
if (CollectionUtils.hasLength(annotations)) {
final List<PAnnotation> pAnnotations = buildPAnnotation(annotations);
pSpanEvent.addAllAnnotation(pAnnotations);
}
return pSpanEvent;
}
use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.
the class GrpcSpanMessageConverter method buildPSpan.
@VisibleForTesting
PSpan buildPSpan(Span span) {
final PSpan.Builder pSpan = PSpan.newBuilder();
pSpan.setVersion(SpanVersion.TRACE_V2);
pSpan.setApplicationServiceType(applicationServiceType);
final TraceRoot traceRoot = span.getTraceRoot();
final TraceId traceId = traceRoot.getTraceId();
final PTransactionId transactionId = newTransactionId(traceId);
pSpan.setTransactionId(transactionId);
pSpan.setSpanId(traceId.getSpanId());
pSpan.setParentSpanId(traceId.getParentSpanId());
pSpan.setStartTime(span.getStartTime());
pSpan.setElapsed(span.getElapsedTime());
pSpan.setServiceType(span.getServiceType());
PAcceptEvent pAcceptEvent = newAcceptEvent(span);
pSpan.setAcceptEvent(pAcceptEvent);
pSpan.setFlag(traceId.getFlags());
Shared shared = span.getTraceRoot().getShared();
pSpan.setErr(shared.getErrorCode());
pSpan.setApiId(span.getApiId());
final IntStringValue exceptionInfo = span.getExceptionInfo();
if (exceptionInfo != null) {
PIntStringValue pIntStringValue = buildPIntStringValue(exceptionInfo);
pSpan.setExceptionInfo(pIntStringValue);
}
pSpan.setLoggingTransactionInfo(shared.getLoggingInfo());
final List<Annotation<?>> annotations = span.getAnnotations();
if (CollectionUtils.hasLength(annotations)) {
final List<PAnnotation> tAnnotations = buildPAnnotation(annotations);
pSpan.addAllAnnotation(tAnnotations);
}
this.spanProcessor.preProcess(span, pSpan);
final List<SpanEvent> spanEventList = span.getSpanEventList();
if (CollectionUtils.hasLength(spanEventList)) {
final List<PSpanEvent> pSpanEvents = buildPSpanEventList(spanEventList);
pSpan.addAllSpanEvent(pSpanEvents);
}
this.spanProcessor.postProcess(span, pSpan);
return pSpan.build();
}
use of com.navercorp.pinpoint.grpc.trace.PSpanEvent 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.grpc.trace.PSpanEvent in project pinpoint by naver.
the class CollectorGrpcSpanFactory method buildSpanChunkBo.
@Override
public SpanChunkBo buildSpanChunkBo(PSpanChunk pSpanChunk, Header header) {
final SpanChunkBo spanChunkBo = this.grpcBinder.bindSpanChunkBo(pSpanChunk, header);
final long acceptedTime = acceptedTimeService.getAcceptedTime();
spanChunkBo.setCollectorAcceptTime(acceptedTime);
final List<PSpanEvent> pSpanEventList = pSpanChunk.getSpanEventList();
List<SpanEventBo> spanEventList = buildSpanEventBoList(pSpanEventList);
spanChunkBo.addSpanEventBoList(spanEventList);
return spanChunkBo;
}
use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.
the class GrpcSpanBinder method bindSpanEventBoList.
public List<SpanEventBo> bindSpanEventBoList(List<PSpanEvent> spanEventList) {
if (CollectionUtils.isEmpty(spanEventList)) {
return Collections.emptyList();
}
List<SpanEventBo> spanEventBoList = new ArrayList<>(spanEventList.size());
SpanEventBo prevSpanEvent = null;
for (PSpanEvent pSpanEvent : spanEventList) {
final SpanEventBo spanEventBo = buildSpanEventBo(pSpanEvent, prevSpanEvent);
spanEventBoList.add(spanEventBo);
prevSpanEvent = spanEventBo;
}
spanEventBoList.sort(SpanEventComparator.INSTANCE);
return spanEventBoList;
}
Aggregations