use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class SpanStreamUDPSenderTest method createSpan.
private Span createSpan(int spanEventSize) throws InterruptedException {
List<SpanEvent> spanEventList = createSpanEventList(spanEventSize);
Span span = new Span();
List<TSpanEvent> tSpanEventList = new ArrayList<>();
for (SpanEvent spanEvent : spanEventList) {
tSpanEventList.add(spanEvent);
}
span.setSpanEventList(tSpanEventList);
return span;
}
use of com.navercorp.pinpoint.profiler.context.SpanEvent 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.profiler.context.SpanEvent 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.profiler.context.SpanEvent in project pinpoint by naver.
the class SpanProcessorV1 method postProcess.
@Override
public void postProcess(SpanChunk spanChunk, TSpanChunk tSpanChunk) {
final TraceRoot traceRoot = spanChunk.getTraceRoot();
final long keyTime = traceRoot.getTraceStartTime();
final List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
if (CollectionUtils.isEmpty(spanEventList)) {
throw new IllegalStateException("SpanChunk.spanEventList is empty");
}
final List<TSpanEvent> tSpanEventList = tSpanChunk.getSpanEventList();
if (CollectionUtils.isEmpty(tSpanEventList)) {
throw new IllegalStateException("TSpanChunk.spanEventList is empty");
}
postEventProcess(spanEventList, tSpanEventList, keyTime);
}
use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.
the class OrderedSpanRecorderTest method createAsyncSpanEvent.
private SpanEvent createAsyncSpanEvent(TraceRoot traceRoot, int startElapsed, int sequence) {
Objects.requireNonNull(traceRoot, "traceRoot");
if (startElapsed < 0) {
throw new IllegalArgumentException("startElapsed cannot be less than 0");
}
if (sequence < 0) {
throw new IllegalArgumentException("sequence cannot be less than 0");
}
SpanEvent event = new SpanEvent();
long startTime = traceRoot.getTraceStartTime() + startElapsed;
event.setStartTime(startTime);
event.setSequence(sequence);
return event;
}
Aggregations