use of com.navercorp.pinpoint.grpc.trace.PTransactionId 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.PTransactionId 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();
}
use of com.navercorp.pinpoint.grpc.trace.PTransactionId 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.PTransactionId in project pinpoint by naver.
the class GrpcSpanChunkHandler method createSimpleSpanChunkLog.
private String createSimpleSpanChunkLog(PSpanChunk spanChunk) {
if (!isDebug) {
return "";
}
StringBuilder log = new StringBuilder();
PTransactionId transactionId = spanChunk.getTransactionId();
log.append(" transactionId:");
log.append(MessageFormatUtils.debugLog(transactionId));
log.append(" spanId:").append(spanChunk.getSpanId());
StringBuilder spanEventSequenceLog = new StringBuilder();
List<PSpanEvent> spanEventList = spanChunk.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.PTransactionId in project pinpoint by naver.
the class GrpcSpanBinder method newSpanChunkBo.
// for test
SpanChunkBo newSpanChunkBo(PSpanChunk pSpanChunk, Header header) {
final SpanChunkBo spanChunkBo = new SpanChunkBo();
spanChunkBo.setVersion(pSpanChunk.getVersion());
spanChunkBo.setAgentId(header.getAgentId());
spanChunkBo.setApplicationId(header.getApplicationName());
spanChunkBo.setAgentStartTime(header.getAgentStartTime());
spanChunkBo.setApplicationServiceType((short) pSpanChunk.getApplicationServiceType());
if (pSpanChunk.hasTransactionId()) {
PTransactionId pTransactionId = pSpanChunk.getTransactionId();
TransactionId transactionId = newTransactionId(pTransactionId, spanChunkBo.getAgentId());
spanChunkBo.setTransactionId(transactionId);
} else {
logger.warn("PTransactionId is not set {}", pSpanChunk);
throw new IllegalStateException("PTransactionId is not set");
}
spanChunkBo.setKeyTime(pSpanChunk.getKeyTime());
spanChunkBo.setSpanId(pSpanChunk.getSpanId());
spanChunkBo.setEndPoint(pSpanChunk.getEndPoint());
return spanChunkBo;
}
Aggregations