use of com.navercorp.pinpoint.common.server.bo.SpanChunkBo in project pinpoint by naver.
the class SpanMapperV2 method bindSpanChunk.
private List<SpanBo> bindSpanChunk(ListMultimap<AgentKey, SpanBo> spanMap, List<SpanChunkBo> spanChunkList) {
for (SpanChunkBo spanChunkBo : spanChunkList) {
AgentKey agentKey = newAgentKey(spanChunkBo);
List<SpanBo> matchedSpanBoList = spanMap.get(agentKey);
if (matchedSpanBoList != null) {
final int spanIdCollisionSize = matchedSpanBoList.size();
if (spanIdCollisionSize > 1) {
// exceptional case dump
logger.warn("spanIdCollision {}", matchedSpanBoList);
}
int agentLevelCollisionCount = 0;
for (SpanBo spanBo : matchedSpanBoList) {
if (StringUtils.equals(spanBo.getAgentId(), spanChunkBo.getAgentId())) {
spanBo.addSpanEventBoList(spanChunkBo.getSpanEventBoList());
agentLevelCollisionCount++;
}
}
if (agentLevelCollisionCount > 1) {
// exceptional case dump
logger.warn("agentLevelCollision {}", matchedSpanBoList);
}
} else {
if (logger.isInfoEnabled()) {
logger.info("Span not exist spanId:{} spanChunk:{}", agentKey, spanChunkBo);
}
}
}
return Lists.newArrayList(spanMap.values());
}
use of com.navercorp.pinpoint.common.server.bo.SpanChunkBo in project pinpoint by naver.
the class SpanMapperV2 method mapRow.
@Override
public List<SpanBo> mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
return Collections.emptyList();
}
byte[] rowKey = result.getRow();
final TransactionId transactionId = this.rowKeyDecoder.decodeRowKey(rowKey);
final Cell[] rawCells = result.rawCells();
ListMultimap<AgentKey, SpanBo> spanMap = LinkedListMultimap.create();
List<SpanChunkBo> spanChunkList = new ArrayList<>();
final SpanDecodingContext decodingContext = new SpanDecodingContext();
decodingContext.setTransactionId(transactionId);
for (Cell cell : rawCells) {
SpanDecoder spanDecoder = null;
// only if family name is "span"
if (CellUtil.matchingFamily(cell, HBaseTables.TRACE_V2_CF_SPAN)) {
decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
final Buffer columnValue = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
spanDecoder = resolveDecoder(columnValue);
final Object decodeObject = spanDecoder.decode(qualifier, columnValue, decodingContext);
if (decodeObject instanceof SpanBo) {
SpanBo spanBo = (SpanBo) decodeObject;
if (logger.isDebugEnabled()) {
logger.debug("spanBo:{}", spanBo);
}
AgentKey agentKey = newAgentKey(spanBo);
spanMap.put(agentKey, spanBo);
} else if (decodeObject instanceof SpanChunkBo) {
SpanChunkBo spanChunkBo = (SpanChunkBo) decodeObject;
if (logger.isDebugEnabled()) {
logger.debug("spanChunkBo:{}", spanChunkBo);
}
spanChunkList.add(spanChunkBo);
}
} else {
logger.warn("Unknown ColumnFamily :{}", Bytes.toStringBinary(CellUtil.cloneFamily(cell)));
}
nextCell(spanDecoder, decodingContext);
}
decodingContext.finish();
return buildSpanBoList(spanMap, spanChunkList);
}
use of com.navercorp.pinpoint.common.server.bo.SpanChunkBo in project pinpoint by naver.
the class SpanChunkHandler method handleSimple.
@Override
public void handleSimple(TBase<?, ?> tbase) {
try {
final SpanChunkBo spanChunkBo = newSpanChunkBo(tbase);
traceDao.insertSpanChunk(spanChunkBo);
final ServiceType applicationServiceType = getApplicationServiceType(spanChunkBo);
List<SpanEventBo> spanEventList = spanChunkBo.getSpanEventBoList();
if (spanEventList != null) {
if (logger.isDebugEnabled()) {
logger.debug("SpanChunk Size:{}", spanEventList.size());
}
// TODO need to batch update later.
for (SpanEventBo spanEvent : spanEventList) {
final ServiceType spanEventType = registry.findServiceType(spanEvent.getServiceType());
if (!spanEventType.isRecordStatistics()) {
continue;
}
// if terminal update statistics
final int elapsed = spanEvent.getEndElapsed();
final boolean hasException = spanEvent.hasException();
/*
* save information to draw a server map based on statistics
*/
// save the information of caller (the spanevent that span called)
statisticsHandler.updateCaller(spanChunkBo.getApplicationId(), applicationServiceType, spanChunkBo.getAgentId(), spanEvent.getDestinationId(), spanEventType, spanEvent.getEndPoint(), elapsed, hasException);
// save the information of callee (the span that called spanevent)
statisticsHandler.updateCallee(spanEvent.getDestinationId(), spanEventType, spanChunkBo.getApplicationId(), applicationServiceType, spanChunkBo.getEndPoint(), elapsed, hasException);
}
}
} catch (Exception e) {
logger.warn("SpanChunk handle error Caused:{}", e.getMessage(), e);
}
}
use of com.navercorp.pinpoint.common.server.bo.SpanChunkBo in project pinpoint by naver.
the class SpanDecoderV0 method readSpanChunk.
private SpanChunkBo readSpanChunk(Buffer qualifier, Buffer columnValue, SpanDecodingContext decodingContext) {
final SpanChunkBo spanChunk = new SpanChunkBo();
final TransactionId transactionId = decodingContext.getTransactionId();
spanChunk.setTransactionId(transactionId);
spanChunk.setCollectorAcceptTime(decodingContext.getCollectorAcceptedTime());
SpanEventBo firstSpanEvent = readQualifier(spanChunk, qualifier);
readSpanChunkValue(columnValue, spanChunk, firstSpanEvent, decodingContext);
return spanChunk;
}
use of com.navercorp.pinpoint.common.server.bo.SpanChunkBo in project pinpoint by naver.
the class SpanEncoderTest method testEncodeSpanColumnValue_complexSpanChunk.
@Test
public void testEncodeSpanColumnValue_complexSpanChunk() throws Exception {
SpanChunkBo spanChunkBo = randomComplexSpanChunk();
assertSpanChunk(spanChunkBo);
}
Aggregations