use of com.navercorp.pinpoint.grpc.trace.PNextEvent 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.PNextEvent in project pinpoint by naver.
the class GrpcSpanBinder method bind.
private void bind(SpanEventBo spanEvent, PSpanEvent pSpanEvent, SpanEventBo prevSpanEvent) {
spanEvent.setSequence((short) pSpanEvent.getSequence());
if (prevSpanEvent == null) {
int startElapsed = pSpanEvent.getStartElapsed();
spanEvent.setStartElapsed(startElapsed);
} else {
int startElapsed = pSpanEvent.getStartElapsed() + prevSpanEvent.getStartElapsed();
spanEvent.setStartElapsed(startElapsed);
}
spanEvent.setEndElapsed(pSpanEvent.getEndElapsed());
spanEvent.setServiceType((short) pSpanEvent.getServiceType());
spanEvent.setApiId(pSpanEvent.getApiId());
// v2 spec
final int depth = pSpanEvent.getDepth();
if (depth == 0) {
// depth compact case
if (prevSpanEvent == null) {
// first spanEvent
spanEvent.setDepth(0);
} else {
spanEvent.setDepth(prevSpanEvent.getDepth());
}
} else {
spanEvent.setDepth(depth);
}
if (pSpanEvent.hasNextEvent()) {
final PNextEvent nextEvent = pSpanEvent.getNextEvent();
final PNextEvent.FieldCase fieldCase = nextEvent.getFieldCase();
if (fieldCase == PNextEvent.FieldCase.MESSAGEEVENT) {
final PMessageEvent messageEvent = nextEvent.getMessageEvent();
spanEvent.setNextSpanId(messageEvent.getNextSpanId());
final String destinationId = messageEvent.getDestinationId();
if (StringUtils.hasLength(destinationId)) {
spanEvent.setDestinationId(destinationId);
}
final String endPoint = messageEvent.getEndPoint();
if (StringUtils.hasLength(endPoint)) {
spanEvent.setEndPoint(endPoint);
}
} else {
logger.info("unknown nextEvent:{}", nextEvent);
}
}
final int asyncEvent = pSpanEvent.getAsyncEvent();
spanEvent.setNextAsyncId(asyncEvent);
List<AnnotationBo> annotationList = buildAnnotationList(pSpanEvent.getAnnotationList());
spanEvent.setAnnotationBoList(annotationList);
if (pSpanEvent.hasExceptionInfo()) {
final PIntStringValue exceptionInfo = pSpanEvent.getExceptionInfo();
spanEvent.setExceptionInfo(exceptionInfo.getIntValue(), getExceptionMessage(exceptionInfo));
}
}
Aggregations