use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.
the class GrpcSpanHandler method createSimpleSpanLog.
private String createSimpleSpanLog(PSpan span) {
if (!isDebug) {
return "";
}
StringBuilder log = new StringBuilder();
PTransactionId transactionId = span.getTransactionId();
log.append(" transactionId:");
log.append(MessageFormatUtils.debugLog(transactionId));
log.append(" spanId:").append(span.getSpanId());
StringBuilder spanEventSequenceLog = new StringBuilder();
List<PSpanEvent> spanEventList = span.getSpanEventList();
for (PSpanEvent pSpanEvent : spanEventList) {
if (pSpanEvent == null) {
continue;
}
spanEventSequenceLog.append(pSpanEvent.getSequence()).append(" ");
}
log.append(" spanEventSequence:").append(spanEventSequenceLog.toString());
return log.toString();
}
use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.
the class SpanClientMock method span.
public void span(int count) {
final int size = 1000;
final byte[] bytes = new byte[size];
for (int i = 0; i < size; i++) {
bytes[i] = (byte) i;
}
PAnnotationValue value = PAnnotationValue.newBuilder().setBinaryValue(ByteString.copyFrom(bytes)).build();
PAnnotation annotation = PAnnotation.newBuilder().setValue(value).build();
PSpanEvent spanEvent = PSpanEvent.newBuilder().addAnnotation(annotation).build();
AtomicLong counter = new AtomicLong();
service.execute(new Runnable() {
@Override
public void run() {
// StreamObserver<PSpanMessage> requestObserver = spanStub.sendSpan(responseObserver);
try {
TimeUnit.SECONDS.sleep(3);
} catch (InterruptedException e) {
}
for (int i = 0; i < count; i++) {
final PSpan span = PSpan.newBuilder().setSpanId(i).addSpanEvent(spanEvent).build();
final PSpanMessage spanMessage = PSpanMessage.newBuilder().setSpan(span).build();
spanStream.onNext(spanMessage);
// requestObserver.onNext(spanMessage);
try {
TimeUnit.MILLISECONDS.sleep(10);
} catch (InterruptedException e) {
}
// System.out.print("S");
}
spanStream.onCompleted();
// requestObserver.onCompleted();
}
});
}
use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.
the class CollectorGrpcSpanFactoryTest method newSpanChunk_overflow.
private PSpanChunk newSpanChunk_overflow() {
PSpanEvent sequenceOverflowEvent = newEvent(MAX_SEQUENCE + 1, 1);
PSpanEvent event = newEvent(MAX_SEQUENCE + 2, 0);
return newSpanChunk(sequenceOverflowEvent, event);
}
use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.
the class CollectorGrpcSpanFactoryTest method newSpanChunk_compact_depth_error.
private PSpanChunk newSpanChunk_compact_depth_error() {
PSpanEvent sequenceOverflowEvent = newEvent(MAX_SEQUENCE + 1, 1);
PSpanEvent event = newEvent(1, 0);
return newSpanChunk(sequenceOverflowEvent, event);
}
use of com.navercorp.pinpoint.grpc.trace.PSpanEvent in project pinpoint by naver.
the class GrpcSpanMessageConverter method buildPSpanChunk.
@VisibleForTesting
PSpanChunk buildPSpanChunk(SpanChunk spanChunk) {
final PSpanChunk.Builder pSpanChunk = PSpanChunk.newBuilder();
pSpanChunk.setVersion(SpanVersion.TRACE_V2);
// tSpanChunk.setApplicationName(applicationName);
// tSpanChunk.setAgentId(agentId);
// tSpanChunk.setAgentStartTime(agentStartTime);
pSpanChunk.setApplicationServiceType(applicationServiceType);
final TraceRoot traceRoot = spanChunk.getTraceRoot();
final TraceId traceId = traceRoot.getTraceId();
final PTransactionId transactionId = newTransactionId(traceId);
pSpanChunk.setTransactionId(transactionId);
pSpanChunk.setSpanId(traceId.getSpanId());
final Shared shared = traceRoot.getShared();
final String endPoint = shared.getEndPoint();
if (endPoint != null) {
pSpanChunk.setEndPoint(endPoint);
}
if (spanChunk instanceof AsyncSpanChunk) {
final AsyncSpanChunk asyncSpanChunk = (AsyncSpanChunk) spanChunk;
final LocalAsyncId localAsyncId = asyncSpanChunk.getLocalAsyncId();
final PLocalAsyncId.Builder pAsyncIdBuilder = PLocalAsyncId.newBuilder();
pAsyncIdBuilder.setAsyncId(localAsyncId.getAsyncId());
pAsyncIdBuilder.setSequence(localAsyncId.getSequence());
final PLocalAsyncId pLocalAsyncId = pAsyncIdBuilder.build();
pSpanChunk.setLocalAsyncId(pLocalAsyncId);
}
this.spanProcessor.preProcess(spanChunk, pSpanChunk);
final List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
if (CollectionUtils.hasLength(spanEventList)) {
final List<PSpanEvent> pSpanEvents = buildPSpanEventList(spanEventList);
pSpanChunk.addAllSpanEvent(pSpanEvents);
}
this.spanProcessor.postProcess(spanChunk, pSpanChunk);
return pSpanChunk.build();
}
Aggregations