Search in sources :

Example 26 with SpanEvent

use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.

the class SpanThriftMessageConverter method buildTSpanChunk.

@VisibleForTesting
TSpanChunk buildTSpanChunk(SpanChunk spanChunk) {
    final TSpanChunk tSpanChunk = new TSpanChunk();
    tSpanChunk.setApplicationName(applicationName);
    tSpanChunk.setAgentId(agentId);
    tSpanChunk.setAgentStartTime(agentStartTime);
    tSpanChunk.setApplicationServiceType(applicationServiceType);
    final TraceRoot traceRoot = spanChunk.getTraceRoot();
    final TraceId traceId = traceRoot.getTraceId();
    final ByteBuffer transactionId = transactionIdEncoder.encodeTransactionId(traceId);
    tSpanChunk.setTransactionId(transactionId);
    tSpanChunk.setSpanId(traceId.getSpanId());
    final Shared shared = traceRoot.getShared();
    tSpanChunk.setEndPoint(shared.getEndPoint());
    if (spanChunk instanceof AsyncSpanChunk) {
        final AsyncSpanChunk asyncSpanChunk = (AsyncSpanChunk) spanChunk;
        final LocalAsyncId localAsyncId = asyncSpanChunk.getLocalAsyncId();
        final TLocalAsyncId tLocalAsyncId = new TLocalAsyncId(localAsyncId.getAsyncId(), localAsyncId.getSequence());
        tSpanChunk.setLocalAsyncId(tLocalAsyncId);
    }
    spanPostProcessor.preProcess(spanChunk, tSpanChunk);
    final List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
    if (CollectionUtils.hasLength(spanEventList)) {
        final List<TSpanEvent> tSpanEvents = buildTSpanEventList(spanEventList);
        tSpanChunk.setSpanEventList(tSpanEvents);
    }
    spanPostProcessor.postProcess(spanChunk, tSpanChunk);
    return tSpanChunk;
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) AsyncSpanChunk(com.navercorp.pinpoint.profiler.context.AsyncSpanChunk) TLocalAsyncId(com.navercorp.pinpoint.thrift.dto.TLocalAsyncId) LocalAsyncId(com.navercorp.pinpoint.profiler.context.LocalAsyncId) TLocalAsyncId(com.navercorp.pinpoint.thrift.dto.TLocalAsyncId) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) Shared(com.navercorp.pinpoint.profiler.context.id.Shared) ByteBuffer(java.nio.ByteBuffer) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 27 with SpanEvent

use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.

the class SpanThriftMessageConverter method buildTSpanEventList.

private List<TSpanEvent> buildTSpanEventList(List<SpanEvent> spanEventList) {
    final int eventSize = spanEventList.size();
    final List<TSpanEvent> tSpanEventList = new ArrayList<>(eventSize);
    for (SpanEvent spanEvent : spanEventList) {
        final TSpanEvent tSpanEvent = buildTSpanEvent(spanEvent);
        tSpanEventList.add(tSpanEvent);
    }
    return tSpanEventList;
}
Also used : ArrayList(java.util.ArrayList) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Example 28 with SpanEvent

use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.

the class SpanStreamUDPSenderTest method createSpanChunk.

private SpanChunk createSpanChunk(int spanEventSize) throws InterruptedException {
    SpanChunkFactory spanChunkFactory = new DefaultSpanChunkFactory("applicationName", "agentId", 0, ServiceType.STAND_ALONE);
    List<SpanEvent> originalSpanEventList = createSpanEventList(spanEventSize);
    SpanChunk spanChunk = spanChunkFactory.create(originalSpanEventList);
    return spanChunk;
}
Also used : SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) DefaultSpanChunkFactory(com.navercorp.pinpoint.profiler.context.DefaultSpanChunkFactory) SpanChunkFactory(com.navercorp.pinpoint.profiler.context.SpanChunkFactory) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) DefaultSpanChunkFactory(com.navercorp.pinpoint.profiler.context.DefaultSpanChunkFactory)

Example 29 with SpanEvent

use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.

the class SpanStreamUDPSenderTest method createSpanEventList.

private List<SpanEvent> createSpanEventList(int size) throws InterruptedException {
    // Span span = new SpanBo(new TSpan());
    Span span = new Span();
    List<SpanEvent> spanEventList = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        SpanEvent spanEvent = new SpanEvent(span);
        spanEvent.markStartTime();
        Thread.sleep(1);
        spanEvent.markAfterTime();
        spanEventList.add(spanEvent);
    }
    return spanEventList;
}
Also used : ArrayList(java.util.ArrayList) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) Span(com.navercorp.pinpoint.profiler.context.Span)

Example 30 with SpanEvent

use of com.navercorp.pinpoint.profiler.context.SpanEvent in project pinpoint by naver.

the class PluginTestAgent method verifyIsLoggingTransactionInfo.

@Override
public void verifyIsLoggingTransactionInfo(LoggingInfo loggingInfo) {
    Object actual = popSpan();
    Span span = null;
    if (actual instanceof Span) {
        span = (Span) actual;
    } else if (actual instanceof SpanEvent) {
        span = ((SpanEvent) actual).getSpan();
    } else {
        throw new IllegalArgumentException("Unexpected type: " + getActual(actual));
    }
    if (span.getLoggingTransactionInfo() != loggingInfo.getCode()) {
        LoggingInfo loggingTransactionInfo = LoggingInfo.searchByCode(span.getLoggingTransactionInfo());
        if (loggingTransactionInfo != null) {
            throw new AssertionError("Expected a Span isLoggingTransactionInfo value with [" + loggingInfo.getName() + "] but was [" + loggingTransactionInfo.getName() + "]. expected: " + loggingInfo.getName() + ", was: " + loggingTransactionInfo.getName());
        } else {
            throw new AssertionError("Expected a Span isLoggingTransactionInfo value with [" + loggingInfo.getName() + "] but loggingTransactionInfo value invalid.");
        }
    }
}
Also used : SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) Span(com.navercorp.pinpoint.profiler.context.Span) LoggingInfo(com.navercorp.pinpoint.common.trace.LoggingInfo)

Aggregations

SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)49 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)23 Test (org.junit.Test)20 Span (com.navercorp.pinpoint.profiler.context.Span)18 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)10 ArrayList (java.util.ArrayList)10 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)9 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)7 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)6 BasePinpointTest (com.navercorp.pinpoint.test.junit4.BasePinpointTest)6 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)5 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)5 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)5 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)4 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)4 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)3 PSpan (com.navercorp.pinpoint.grpc.trace.PSpan)3 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)3 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3