use of com.navercorp.pinpoint.common.trace.SlotType in project pinpoint by naver.
the class ActiveTraceCodecV1 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> 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.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 ActiveTraceCodecV1 method encodeValues.
@Override
public void encodeValues(Buffer valueBuffer, List<ActiveTraceBo> activeTraceBos) {
if (CollectionUtils.isEmpty(activeTraceBos)) {
throw new IllegalArgumentException("activeTraceBos must not be empty");
}
final int numValues = activeTraceBos.size();
valueBuffer.putVInt(numValues);
List<Long> timestamps = new ArrayList<Long>(numValues);
UnsignedShortEncodingStrategy.Analyzer.Builder versionAnalyzerBuilder = new UnsignedShortEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder schemaTypeAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder fastTraceCountsAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder normalTraceCountsAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder slowTraceCountsAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder verySlowTraceCountsAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
for (ActiveTraceBo activeTraceBo : activeTraceBos) {
timestamps.add(activeTraceBo.getTimestamp());
versionAnalyzerBuilder.addValue(activeTraceBo.getVersion());
schemaTypeAnalyzerBuilder.addValue(activeTraceBo.getHistogramSchemaType());
final Map<SlotType, Integer> activeTraceCounts = activeTraceBo.getActiveTraceCounts();
fastTraceCountsAnalyzerBuilder.addValue(MapUtils.getIntValue(activeTraceCounts, SlotType.FAST, ActiveTraceBo.UNCOLLECTED_ACTIVE_TRACE_COUNT));
normalTraceCountsAnalyzerBuilder.addValue(MapUtils.getIntValue(activeTraceCounts, SlotType.NORMAL, ActiveTraceBo.UNCOLLECTED_ACTIVE_TRACE_COUNT));
slowTraceCountsAnalyzerBuilder.addValue(MapUtils.getIntValue(activeTraceCounts, SlotType.SLOW, ActiveTraceBo.UNCOLLECTED_ACTIVE_TRACE_COUNT));
verySlowTraceCountsAnalyzerBuilder.addValue(MapUtils.getIntValue(activeTraceCounts, SlotType.VERY_SLOW, ActiveTraceBo.UNCOLLECTED_ACTIVE_TRACE_COUNT));
}
this.codec.encodeTimestamps(valueBuffer, timestamps);
this.encodeDataPoints(valueBuffer, versionAnalyzerBuilder.build(), schemaTypeAnalyzerBuilder.build(), fastTraceCountsAnalyzerBuilder.build(), normalTraceCountsAnalyzerBuilder.build(), slowTraceCountsAnalyzerBuilder.build(), verySlowTraceCountsAnalyzerBuilder.build());
}
use of com.navercorp.pinpoint.common.trace.SlotType in project pinpoint by naver.
the class ActiveTraceCodecV2 method encodeValues.
@Override
public void encodeValues(Buffer valueBuffer, List<ActiveTraceBo> activeTraceBos) {
if (CollectionUtils.isEmpty(activeTraceBos)) {
throw new IllegalArgumentException("activeTraceBos must not be empty");
}
final int numValues = activeTraceBos.size();
valueBuffer.putVInt(numValues);
List<Long> startTimestamps = new ArrayList<Long>(numValues);
List<Long> timestamps = new ArrayList<Long>(numValues);
UnsignedShortEncodingStrategy.Analyzer.Builder versionAnalyzerBuilder = new UnsignedShortEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder schemaTypeAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder fastTraceCountsAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder normalTraceCountsAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder slowTraceCountsAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
UnsignedIntegerEncodingStrategy.Analyzer.Builder verySlowTraceCountsAnalyzerBuilder = new UnsignedIntegerEncodingStrategy.Analyzer.Builder();
for (ActiveTraceBo activeTraceBo : activeTraceBos) {
startTimestamps.add(activeTraceBo.getStartTimestamp());
timestamps.add(activeTraceBo.getTimestamp());
versionAnalyzerBuilder.addValue(activeTraceBo.getVersion());
schemaTypeAnalyzerBuilder.addValue(activeTraceBo.getHistogramSchemaType());
final Map<SlotType, Integer> activeTraceCounts = activeTraceBo.getActiveTraceCounts();
fastTraceCountsAnalyzerBuilder.addValue(MapUtils.getIntValue(activeTraceCounts, SlotType.FAST, ActiveTraceBo.UNCOLLECTED_ACTIVE_TRACE_COUNT));
normalTraceCountsAnalyzerBuilder.addValue(MapUtils.getIntValue(activeTraceCounts, SlotType.NORMAL, ActiveTraceBo.UNCOLLECTED_ACTIVE_TRACE_COUNT));
slowTraceCountsAnalyzerBuilder.addValue(MapUtils.getIntValue(activeTraceCounts, SlotType.SLOW, ActiveTraceBo.UNCOLLECTED_ACTIVE_TRACE_COUNT));
verySlowTraceCountsAnalyzerBuilder.addValue(MapUtils.getIntValue(activeTraceCounts, SlotType.VERY_SLOW, ActiveTraceBo.UNCOLLECTED_ACTIVE_TRACE_COUNT));
}
this.codec.encodeValues(valueBuffer, UnsignedLongEncodingStrategy.REPEAT_COUNT, startTimestamps);
this.codec.encodeTimestamps(valueBuffer, timestamps);
this.encodeDataPoints(valueBuffer, versionAnalyzerBuilder.build(), schemaTypeAnalyzerBuilder.build(), fastTraceCountsAnalyzerBuilder.build(), normalTraceCountsAnalyzerBuilder.build(), slowTraceCountsAnalyzerBuilder.build(), verySlowTraceCountsAnalyzerBuilder.build());
}
use of com.navercorp.pinpoint.common.trace.SlotType in project pinpoint by naver.
the class ActiveTraceHistogramBoTest method null_activeTraceCounts_should_return_valid_map_per_version.
@Test
public void null_activeTraceCounts_should_return_valid_map_per_version() {
// Given
final int validVersion = 0;
final int expectedHistogramSchemaType = 1;
final Map<SlotType, Integer> expectedActiveTraceCountMap = new HashMap<SlotType, Integer>();
expectedActiveTraceCountMap.put(SlotType.FAST, 0);
expectedActiveTraceCountMap.put(SlotType.NORMAL, 0);
expectedActiveTraceCountMap.put(SlotType.SLOW, 0);
expectedActiveTraceCountMap.put(SlotType.VERY_SLOW, 0);
// When
ActiveTraceHistogramBo expectedBo = new ActiveTraceHistogramBo(validVersion, expectedHistogramSchemaType, null);
byte[] serializedBo = expectedBo.writeValue();
ActiveTraceHistogramBo deserializedBo = new ActiveTraceHistogramBo(serializedBo);
// Then
assertEquals(validVersion, deserializedBo.getVersion());
assertEquals(expectedHistogramSchemaType, deserializedBo.getHistogramSchemaType());
assertEquals(expectedActiveTraceCountMap, deserializedBo.getActiveTraceCountMap());
}
use of com.navercorp.pinpoint.common.trace.SlotType in project pinpoint by naver.
the class LegacyAgentStatChartGroup method addActiveTraceData.
private void addActiveTraceData(AgentStat agentStat) {
long timestamp = agentStat.getTimestamp();
HistogramSchema schema = agentStat.getHistogramSchema();
if (schema != null) {
Map<SlotType, Integer> activeTraceCounts = agentStat.getActiveTraceCounts();
int fastCount = activeTraceCounts.get(SlotType.FAST);
if (fastCount != UNCOLLECTED_DATA) {
TitledDataPoint<Long, Integer> fastDataPoint = new TitledDataPoint<>(schema.getFastSlot().getSlotName(), timestamp, fastCount);
this.activeTraceFastChartBuilder.addDataPoint(fastDataPoint);
}
int normalCount = activeTraceCounts.get(SlotType.NORMAL);
if (normalCount != UNCOLLECTED_DATA) {
TitledDataPoint<Long, Integer> normalDataPoint = new TitledDataPoint<>(schema.getNormalSlot().getSlotName(), timestamp, normalCount);
this.activeTraceNormalChartBuilder.addDataPoint(normalDataPoint);
}
int slowCount = activeTraceCounts.get(SlotType.SLOW);
if (slowCount != UNCOLLECTED_DATA) {
TitledDataPoint<Long, Integer> slowDataPoint = new TitledDataPoint<>(schema.getSlowSlot().getSlotName(), timestamp, slowCount);
this.activeTraceSlowChartBuilder.addDataPoint(slowDataPoint);
}
int verySlowCount = activeTraceCounts.get(SlotType.VERY_SLOW);
if (verySlowCount != UNCOLLECTED_DATA) {
TitledDataPoint<Long, Integer> verySlowDataPoint = new TitledDataPoint<>(schema.getVerySlowSlot().getSlotName(), timestamp, verySlowCount);
this.activeTraceVerySlowChartBuilder.addDataPoint(verySlowDataPoint);
}
}
}
Aggregations