use of com.navercorp.pinpoint.common.server.bo.SpanChunkBo in project pinpoint by naver.
the class SpanChunkSerializerV2 method serialize.
@Override
public void serialize(SpanChunkBo spanChunkBo, Put put, SerializationContext context) {
Objects.requireNonNull(spanChunkBo, "spanChunkBo");
SpanEncodingContext<SpanChunkBo> encodingContext = new SpanEncodingContext<>(spanChunkBo);
ByteBuffer qualifier = spanEncoder.encodeSpanChunkQualifier(encodingContext);
ByteBuffer columnValue = spanEncoder.encodeSpanChunkColumnValue(encodingContext);
long acceptedTime = put.getTimeStamp();
put.addColumn(HbaseColumnFamily.TRACE_V2_SPAN.getName(), qualifier, acceptedTime, columnValue);
}
use of com.navercorp.pinpoint.common.server.bo.SpanChunkBo in project pinpoint by naver.
the class CollectorGrpcSpanFactory method buildSpanChunkBo.
@Override
public SpanChunkBo buildSpanChunkBo(PSpanChunk pSpanChunk, Header header) {
final SpanChunkBo spanChunkBo = this.grpcBinder.bindSpanChunkBo(pSpanChunk, header);
final long acceptedTime = acceptedTimeService.getAcceptedTime();
spanChunkBo.setCollectorAcceptTime(acceptedTime);
final List<PSpanEvent> pSpanEventList = pSpanChunk.getSpanEventList();
List<SpanEventBo> spanEventList = buildSpanEventBoList(pSpanEventList);
spanChunkBo.addSpanEventBoList(spanEventList);
return spanChunkBo;
}
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 (CollectionUtils.hasLength(matchedSpanBoList)) {
final int spanIdCollisionSize = matchedSpanBoList.size();
if (spanIdCollisionSize > 1) {
// exceptional case dump
logger.warn("spanIdCollision {}", matchedSpanBoList);
}
int agentLevelCollisionCount = 0;
for (SpanBo spanBo : matchedSpanBoList) {
if (isChildSpanChunk(spanBo, spanChunkBo)) {
spanBo.addSpanChunkBo(spanChunkBo);
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 new ArrayList<>(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);
final BufferFactory bufferFactory = new BufferFactory(cacheSize);
for (Cell cell : rawCells) {
SpanDecoder spanDecoder = null;
// only if family name is "span"
if (CellUtil.matchingFamily(cell, HbaseColumnFamily.TRACE_V2_SPAN.getName())) {
decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
final Buffer qualifier = bufferFactory.createBuffer(CellUtil.cloneQualifier(cell));
final Buffer columnValue = bufferFactory.createBuffer(CellUtil.cloneValue(cell));
spanDecoder = resolveDecoder(columnValue);
final Object decodeObject = spanDecoder.decode(qualifier, columnValue, decodingContext);
if (decodeObject instanceof SpanBo) {
SpanBo spanBo = (SpanBo) decodeObject;
if (logger.isTraceEnabled()) {
logger.trace("spanBo:{}", spanBo);
}
AgentKey agentKey = newAgentKey(spanBo);
spanMap.put(agentKey, spanBo);
} else if (decodeObject instanceof SpanChunkBo) {
SpanChunkBo spanChunkBo = (SpanChunkBo) decodeObject;
if (logger.isTraceEnabled()) {
logger.trace("spanChunkBo:{}", spanChunkBo);
}
spanChunkList.add(spanChunkBo);
}
} else {
if (logger.isWarnEnabled()) {
String columnFamily = Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
logger.warn("Unknown ColumnFamily :{}", columnFamily);
}
}
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 SpanReader method accept.
public boolean accept(SpanVisitor spanVisitor) {
Objects.requireNonNull(spanVisitor, "spanVisitor");
if (CollectionUtils.isEmpty(spanBoList)) {
return SpanVisitor.REJECT;
}
for (SpanBo spanBo : spanBoList) {
if (spanVisitor.visit(spanBo)) {
return SpanVisitor.ACCEPT;
}
final List<SpanEventBo> spanEventBoList = spanBo.getSpanEventBoList();
if (visitSpanEventList(spanVisitor, spanEventBoList)) {
return SpanVisitor.ACCEPT;
}
List<SpanChunkBo> spanChunkBoList = spanBo.getSpanChunkBoList();
if (CollectionUtils.hasLength(spanChunkBoList)) {
for (SpanChunkBo spanChunkBo : spanChunkBoList) {
if (spanVisitor.visit(spanChunkBo)) {
return SpanVisitor.ACCEPT;
}
List<SpanEventBo> spanChunkEventBoList = spanChunkBo.getSpanEventBoList();
if (visitSpanEventList(spanVisitor, spanChunkEventBoList)) {
return SpanVisitor.ACCEPT;
}
}
}
}
return SpanVisitor.REJECT;
}
Aggregations