Search in sources :

Example 6 with LocalAsyncIdBo

use of com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo in project pinpoint by naver.

the class SpanFactory method fullScanLocalAsyncIdBo.

@VisibleForTesting
LocalAsyncIdBo fullScanLocalAsyncIdBo(TSpanChunk tSpanChunk) {
    int asyncId = -1;
    int asyncSequence = -1;
    boolean first = true;
    boolean asyncIdNotSame = false;
    for (TSpanEvent tSpanEvent : tSpanChunk.getSpanEventList()) {
        if (first) {
            first = false;
            if (isSetAsyncId(tSpanEvent)) {
                asyncId = tSpanEvent.getAsyncId();
                asyncSequence = tSpanEvent.getAsyncSequence();
            }
        } else {
            if (isSetAsyncId(tSpanEvent)) {
                if (asyncId != tSpanEvent.getAsyncId()) {
                    asyncIdNotSame = true;
                    break;
                }
                if (asyncSequence != tSpanEvent.getAsyncSequence()) {
                    asyncIdNotSame = true;
                    break;
                }
            }
        }
    }
    if (asyncIdNotSame) {
        logger.warn("AsyncId consistency is broken. tSpanChunk:{}", tSpanChunk);
        return null;
    }
    if (asyncId != -1 && asyncSequence != -1) {
        return new LocalAsyncIdBo(asyncId, asyncSequence);
    }
    // non async
    return null;
}
Also used : LocalAsyncIdBo(com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 7 with LocalAsyncIdBo

use of com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo in project pinpoint by naver.

the class GrpcSpanBinder method bindSpanChunkBo.

public SpanChunkBo bindSpanChunkBo(PSpanChunk pSpanChunk, Header header) {
    checkVersion(pSpanChunk.getVersion());
    final SpanChunkBo spanChunkBo = newSpanChunkBo(pSpanChunk, header);
    if (pSpanChunk.hasLocalAsyncId()) {
        final PLocalAsyncId pLocalAsyncId = pSpanChunk.getLocalAsyncId();
        LocalAsyncIdBo localAsyncIdBo = new LocalAsyncIdBo(pLocalAsyncId.getAsyncId(), pLocalAsyncId.getSequence());
        spanChunkBo.setLocalAsyncId(localAsyncIdBo);
    }
    return spanChunkBo;
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) PLocalAsyncId(com.navercorp.pinpoint.grpc.trace.PLocalAsyncId) LocalAsyncIdBo(com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo)

Example 8 with LocalAsyncIdBo

use of com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo in project pinpoint by naver.

the class SpanFactoryTest method testFullScanLocalAsyncIdBo.

@Test
public void testFullScanLocalAsyncIdBo() {
    int asyncId = 1;
    short asyncSequence = 0;
    TSpanEvent tSpanEvent = new TSpanEvent();
    tSpanEvent.setAsyncId(asyncId);
    tSpanEvent.setAsyncSequence(asyncSequence);
    TSpanChunk tSpanChunk = new TSpanChunk();
    tSpanChunk.setSpanEventList(Arrays.asList(tSpanEvent, tSpanEvent));
    LocalAsyncIdBo localAsyncIdBo = spanFactory.fullScanLocalAsyncIdBo(tSpanChunk);
    Assert.assertEquals(localAsyncIdBo.getAsyncId(), asyncId);
    Assert.assertEquals(localAsyncIdBo.getSequence(), asyncSequence);
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) LocalAsyncIdBo(com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Example 9 with LocalAsyncIdBo

use of com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo in project pinpoint by naver.

the class SpanFactoryTest method testFastLocalAsyncIdBo.

@Test
public void testFastLocalAsyncIdBo() {
    int asyncId = 1;
    short asyncSequence = 0;
    TSpanEvent tSpanEvent = new TSpanEvent();
    tSpanEvent.setAsyncId(asyncId);
    tSpanEvent.setAsyncSequence(asyncSequence);
    LocalAsyncIdBo localAsyncIdBo = spanFactory.fastLocalAsyncIdBo(Collections.singletonList(tSpanEvent));
    Assert.assertEquals(localAsyncIdBo.getAsyncId(), asyncId);
    Assert.assertEquals(localAsyncIdBo.getSequence(), asyncSequence);
}
Also used : LocalAsyncIdBo(com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Example 10 with LocalAsyncIdBo

use of com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo in project pinpoint by naver.

the class SpanAsyncEventMap method add.

private boolean add(SpanBo spanBo, final SpanChunkBo spanChunkBo) {
    final LocalAsyncIdBo localAsyncId = spanChunkBo.getLocalAsyncId();
    if (localAsyncId == null) {
        return false;
    }
    List<SpanEventBo> spanEventBoList = spanChunkBo.getSpanEventBoList();
    if (CollectionUtils.isEmpty(spanEventBoList)) {
        return false;
    }
    final List<Align> alignList = toAlignList(spanBo, spanChunkBo, spanEventBoList);
    final int id = localAsyncId.getAsyncId();
    Map<Integer, List<Align>> subMap = map.computeIfAbsent(id, k -> new HashMap<>());
    final int sequence = localAsyncId.getSequence();
    final List<Align> exist = subMap.get(sequence);
    if (exist != null) {
        exist.addAll(alignList);
    } else {
        subMap.put(sequence, alignList);
    }
    return true;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) LocalAsyncIdBo(com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Aggregations

LocalAsyncIdBo (com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo)11 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)7 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)4 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)4 Test (org.junit.Test)4 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)2 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)2 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1