Search in sources :

Example 1 with ActiveTraceBo

use of com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo 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;
}
Also used : HashMap(java.util.HashMap) BitCountingHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder) ArrayList(java.util.ArrayList) SlotType(com.navercorp.pinpoint.common.trace.SlotType) AgentStatHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder) ActiveTraceBo(com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)

Example 2 with ActiveTraceBo

use of com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo 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());
}
Also used : UnsignedIntegerEncodingStrategy(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedIntegerEncodingStrategy) ArrayList(java.util.ArrayList) StrategyAnalyzer(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.StrategyAnalyzer) SlotType(com.navercorp.pinpoint.common.trace.SlotType) UnsignedShortEncodingStrategy(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedShortEncodingStrategy) ActiveTraceBo(com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)

Example 3 with ActiveTraceBo

use of com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo 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());
}
Also used : UnsignedIntegerEncodingStrategy(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedIntegerEncodingStrategy) ArrayList(java.util.ArrayList) StrategyAnalyzer(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.StrategyAnalyzer) SlotType(com.navercorp.pinpoint.common.trace.SlotType) UnsignedShortEncodingStrategy(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedShortEncodingStrategy) ActiveTraceBo(com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)

Example 4 with ActiveTraceBo

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

the class AgentStatBatchMapper method map.

@Override
public AgentStatBo map(TAgentStatBatch tAgentStatBatch) {
    if (!tAgentStatBatch.isSetAgentStats()) {
        return null;
    }
    AgentStatBo agentStatBo = new AgentStatBo();
    final String agentId = tAgentStatBatch.getAgentId();
    final long startTimestamp = tAgentStatBatch.getStartTimestamp();
    agentStatBo.setAgentId(agentId);
    List<JvmGcBo> jvmGcBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<JvmGcDetailedBo> jvmGcDetailedBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<CpuLoadBo> cpuLoadBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<TransactionBo> transactionBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<ActiveTraceBo> activeTraceBos = new ArrayList<>(tAgentStatBatch.getAgentStatsSize());
    List<DataSourceListBo> dataSourceListBos = new ArrayList<DataSourceListBo>(tAgentStatBatch.getAgentStatsSize());
    for (TAgentStat tAgentStat : tAgentStatBatch.getAgentStats()) {
        final long timestamp = tAgentStat.getTimestamp();
        // jvmGc
        if (tAgentStat.isSetGc()) {
            JvmGcBo jvmGcBo = this.jvmGcBoMapper.map(tAgentStat.getGc());
            setBaseData(jvmGcBo, agentId, startTimestamp, timestamp);
            jvmGcBos.add(jvmGcBo);
        }
        // jvmGcDetailed
        if (tAgentStat.isSetGc()) {
            if (tAgentStat.getGc().isSetJvmGcDetailed()) {
                JvmGcDetailedBo jvmGcDetailedBo = this.jvmGcDetailedBoMapper.map(tAgentStat.getGc().getJvmGcDetailed());
                setBaseData(jvmGcDetailedBo, agentId, startTimestamp, timestamp);
                jvmGcDetailedBos.add(jvmGcDetailedBo);
            }
        }
        // cpuLoad
        if (tAgentStat.isSetCpuLoad()) {
            CpuLoadBo cpuLoadBo = this.cpuLoadBoMapper.map(tAgentStat.getCpuLoad());
            setBaseData(cpuLoadBo, agentId, startTimestamp, timestamp);
            cpuLoadBos.add(cpuLoadBo);
        }
        // transaction
        if (tAgentStat.isSetTransaction()) {
            TransactionBo transactionBo = this.transactionBoMapper.map(tAgentStat.getTransaction());
            setBaseData(transactionBo, agentId, startTimestamp, timestamp);
            transactionBo.setCollectInterval(tAgentStat.getCollectInterval());
            transactionBos.add(transactionBo);
        }
        // activeTrace
        if (tAgentStat.isSetActiveTrace() && tAgentStat.getActiveTrace().isSetHistogram()) {
            ActiveTraceBo activeTraceBo = this.activeTraceBoMapper.map(tAgentStat.getActiveTrace());
            setBaseData(activeTraceBo, agentId, startTimestamp, timestamp);
            activeTraceBos.add(activeTraceBo);
        }
        // datasource
        if (tAgentStat.isSetDataSourceList()) {
            DataSourceListBo dataSourceListBo = new DataSourceListBo();
            setBaseData(dataSourceListBo, agentId, startTimestamp, timestamp);
            TDataSourceList dataSourceList = tAgentStat.getDataSourceList();
            if (dataSourceList.getDataSourceListSize() > 0) {
                for (TDataSource dataSource : dataSourceList.getDataSourceList()) {
                    DataSourceBo dataSourceBo = dataSourceBoMapper.map(dataSource);
                    setBaseData(dataSourceBo, agentId, startTimestamp, timestamp);
                    dataSourceListBo.add(dataSourceBo);
                }
            }
            dataSourceListBos.add(dataSourceListBo);
        }
    }
    agentStatBo.setJvmGcBos(jvmGcBos);
    agentStatBo.setJvmGcDetailedBos(jvmGcDetailedBos);
    agentStatBo.setCpuLoadBos(cpuLoadBos);
    agentStatBo.setTransactionBos(transactionBos);
    agentStatBo.setActiveTraceBos(activeTraceBos);
    agentStatBo.setDataSourceListBos(dataSourceListBos);
    return agentStatBo;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) AgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo) TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) JvmGcDetailedBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcDetailedBo) ArrayList(java.util.ArrayList) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo) TDataSource(com.navercorp.pinpoint.thrift.dto.TDataSource) TDataSourceList(com.navercorp.pinpoint.thrift.dto.TDataSourceList) DataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo) TransactionBo(com.navercorp.pinpoint.common.server.bo.stat.TransactionBo) ActiveTraceBo(com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)

Example 5 with ActiveTraceBo

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

the class TestAgentStatFactory method createActiveTraceBos.

public static List<ActiveTraceBo> createActiveTraceBos(String agentId, long startTimestamp, long initialTimestamp, int numValues) {
    List<ActiveTraceBo> activeTraceBos = new ArrayList<ActiveTraceBo>(numValues);
    List<Long> startTimestamps = createStartTimestamps(startTimestamp, numValues);
    List<Long> timestamps = createTimestamps(initialTimestamp, numValues);
    List<Integer> fastTraceCounts = TestAgentStatDataPointFactory.INTEGER.createRandomValues(0, 1000, numValues);
    List<Integer> normalTraceCounts = TestAgentStatDataPointFactory.INTEGER.createRandomValues(0, 1000, numValues);
    List<Integer> slowTraceCounts = TestAgentStatDataPointFactory.INTEGER.createRandomValues(0, 1000, numValues);
    List<Integer> verySlowTraceCounts = TestAgentStatDataPointFactory.INTEGER.createRandomValues(0, 1000, numValues);
    int histogramSchemaType = 1;
    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.setHistogramSchemaType(histogramSchemaType);
        if (RANDOM.nextInt(5) > 0) {
            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);
        } else {
            activeTraceBo.setActiveTraceCounts(Collections.<SlotType, Integer>emptyMap());
        }
        activeTraceBos.add(activeTraceBo);
    }
    return activeTraceBos;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ActiveTraceBo(com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo) SlotType(com.navercorp.pinpoint.common.trace.SlotType)

Aggregations

ActiveTraceBo (com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)11 SlotType (com.navercorp.pinpoint.common.trace.SlotType)7 ArrayList (java.util.ArrayList)7 SampledActiveTrace (com.navercorp.pinpoint.web.vo.stat.SampledActiveTrace)3 HashMap (java.util.HashMap)3 AgentStatHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder)2 BitCountingHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder)2 StrategyAnalyzer (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.StrategyAnalyzer)2 UnsignedIntegerEncodingStrategy (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedIntegerEncodingStrategy)2 UnsignedShortEncodingStrategy (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedShortEncodingStrategy)2 AgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo)2 CpuLoadBo (com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo)2 DataSourceBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo)2 DataSourceListBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo)2 JvmGcBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)2 JvmGcDetailedBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcDetailedBo)2 TransactionBo (com.navercorp.pinpoint.common.server.bo.stat.TransactionBo)2 TDataSource (com.navercorp.pinpoint.thrift.dto.TDataSource)2 TDataSourceList (com.navercorp.pinpoint.thrift.dto.TDataSourceList)2 SampledAgentStatResultExtractor (com.navercorp.pinpoint.web.mapper.stat.SampledAgentStatResultExtractor)2