use of com.navercorp.pinpoint.common.trace.SlotType in project pinpoint by naver.
the class ActiveTraceBoMapper method map.
@Override
public ActiveTraceBo map(TActiveTrace tActiveTrace) {
TActiveTraceHistogram tActiveTraceHistogram = tActiveTrace.getHistogram();
Map<SlotType, Integer> activeTraceCounts = createActiveTraceCountMap(tActiveTraceHistogram.getActiveTraceCount());
ActiveTraceBo activeTraceBo = new ActiveTraceBo();
activeTraceBo.setVersion(tActiveTraceHistogram.getVersion());
activeTraceBo.setHistogramSchemaType(tActiveTraceHistogram.getHistogramSchemaType());
activeTraceBo.setActiveTraceCounts(activeTraceCounts);
return activeTraceBo;
}
use of com.navercorp.pinpoint.common.trace.SlotType in project pinpoint by naver.
the class ActiveTraceCodecV2 method decodeValues.
@Override
public List<ActiveTraceBo> decodeValues(Buffer valueBuffer, AgentStatDecodingContext decodingContext) {
final String agentId = decodingContext.getAgentId();
final long baseTimestamp = decodingContext.getBaseTimestamp();
final long timestampDelta = decodingContext.getTimestampDelta();
final long initialTimestamp = baseTimestamp + timestampDelta;
int numValues = valueBuffer.readVInt();
List<Long> startTimestamps = this.codec.decodeValues(valueBuffer, UnsignedLongEncodingStrategy.REPEAT_COUNT, numValues);
List<Long> timestamps = this.codec.decodeTimestamps(initialTimestamp, valueBuffer, numValues);
// decode headers
final byte[] header = valueBuffer.readPrefixedBytes();
AgentStatHeaderDecoder headerDecoder = new BitCountingHeaderDecoder(header);
EncodingStrategy<Short> versionEncodingStrategy = UnsignedShortEncodingStrategy.getFromCode(headerDecoder.getCode());
EncodingStrategy<Integer> schemaTypeEncodingStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
EncodingStrategy<Integer> fastTraceCountsEncodingStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
EncodingStrategy<Integer> normalTraceCountsEncodingStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
EncodingStrategy<Integer> slowTraceCountsEncodingStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
EncodingStrategy<Integer> verySlowTraceCountsEncodingStrategy = UnsignedIntegerEncodingStrategy.getFromCode(headerDecoder.getCode());
// decode values
List<Short> versions = this.codec.decodeValues(valueBuffer, versionEncodingStrategy, numValues);
List<Integer> schemaTypes = this.codec.decodeValues(valueBuffer, schemaTypeEncodingStrategy, numValues);
List<Integer> fastTraceCounts = this.codec.decodeValues(valueBuffer, fastTraceCountsEncodingStrategy, numValues);
List<Integer> normalTraceCounts = this.codec.decodeValues(valueBuffer, normalTraceCountsEncodingStrategy, numValues);
List<Integer> slowTraceCounts = this.codec.decodeValues(valueBuffer, slowTraceCountsEncodingStrategy, numValues);
List<Integer> verySlowTraceCounts = this.codec.decodeValues(valueBuffer, verySlowTraceCountsEncodingStrategy, numValues);
List<ActiveTraceBo> activeTraceBos = new ArrayList<ActiveTraceBo>(numValues);
for (int i = 0; i < numValues; ++i) {
ActiveTraceBo activeTraceBo = new ActiveTraceBo();
activeTraceBo.setAgentId(agentId);
activeTraceBo.setStartTimestamp(startTimestamps.get(i));
activeTraceBo.setTimestamp(timestamps.get(i));
activeTraceBo.setVersion(versions.get(i));
activeTraceBo.setHistogramSchemaType(schemaTypes.get(i));
Map<SlotType, Integer> activeTraceCounts = new HashMap<SlotType, Integer>();
activeTraceCounts.put(SlotType.FAST, fastTraceCounts.get(i));
activeTraceCounts.put(SlotType.NORMAL, normalTraceCounts.get(i));
activeTraceCounts.put(SlotType.SLOW, slowTraceCounts.get(i));
activeTraceCounts.put(SlotType.VERY_SLOW, verySlowTraceCounts.get(i));
activeTraceBo.setActiveTraceCounts(activeTraceCounts);
activeTraceBos.add(activeTraceBo);
}
return activeTraceBos;
}
use of com.navercorp.pinpoint.common.trace.SlotType in project pinpoint by naver.
the class ActiveTraceHistogramFactory method createHistogram.
public ActiveTraceHistogram createHistogram() {
Map<SlotType, IntAdder> mappedSlot = new LinkedHashMap<SlotType, IntAdder>(activeTraceSlotsCount);
for (SlotType slotType : ACTIVE_TRACE_SLOTS_ORDER) {
mappedSlot.put(slotType, new IntAdder(0));
}
long currentTime = System.currentTimeMillis();
List<ActiveTraceInfo> collectedActiveTraceInfo = activeTraceRepository.collect();
for (ActiveTraceInfo activeTraceInfo : collectedActiveTraceInfo) {
HistogramSlot slot = histogramSchema.findHistogramSlot((int) (currentTime - activeTraceInfo.getStartTime()), false);
mappedSlot.get(slot.getSlotType()).incrementAndGet();
}
List<Integer> activeTraceCount = new ArrayList<Integer>(activeTraceSlotsCount);
for (IntAdder statusCount : mappedSlot.values()) {
activeTraceCount.add(statusCount.get());
}
return new ActiveTraceHistogram(this.histogramSchema, activeTraceCount);
}
Aggregations