Search in sources :

Example 6 with PCustomMetric

use of com.navercorp.pinpoint.grpc.trace.PCustomMetric in project pinpoint by naver.

the class GrpcCustomMetricMessageConverter method toMessage.

@Override
public PCustomMetricMessage toMessage(MetricType message) {
    Objects.requireNonNull(message, "message");
    if (message instanceof AgentCustomMetricSnapshotBatch) {
        AgentCustomMetricSnapshotBatch agentCustomMetricSnapshotBatch = (AgentCustomMetricSnapshotBatch) message;
        List<AgentCustomMetricSnapshot> agentCustomMetricSnapshotList = agentCustomMetricSnapshotBatch.getAgentCustomMetricSnapshotList();
        Set<String> metricNameSet = new HashSet<>();
        for (AgentCustomMetricSnapshot agentCustomMetricSnapshot : agentCustomMetricSnapshotList) {
            metricNameSet.addAll(agentCustomMetricSnapshot.getMetricNameSet());
        }
        PCustomMetricMessage.Builder builder = PCustomMetricMessage.newBuilder();
        for (int i = 0; i < agentCustomMetricSnapshotList.size(); i++) {
            AgentCustomMetricSnapshot agentCustomMetricSnapshot = agentCustomMetricSnapshotList.get(i);
            builder.addTimestamp(agentCustomMetricSnapshot.getTimestamp());
            builder.addCollectInterval(agentCustomMetricSnapshot.getCollectInterval());
        }
        for (String metricName : metricNameSet) {
            PCustomMetric pCustomMetric = create(metricName, agentCustomMetricSnapshotList);
            if (pCustomMetric != null) {
                builder.addCustomMetrics(pCustomMetric);
            }
        }
        return builder.build();
    } else {
        throw new IllegalArgumentException("Not supported Object. clazz:" + message.getClass());
    }
}
Also used : AgentCustomMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot) PCustomMetricMessage(com.navercorp.pinpoint.grpc.trace.PCustomMetricMessage) PCustomMetric(com.navercorp.pinpoint.grpc.trace.PCustomMetric) AgentCustomMetricSnapshotBatch(com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshotBatch) HashSet(java.util.HashSet)

Aggregations

PCustomMetric (com.navercorp.pinpoint.grpc.trace.PCustomMetric)6 CustomMetricVo (com.navercorp.pinpoint.profiler.monitor.metric.custom.CustomMetricVo)5 PCustomMetricMessage (com.navercorp.pinpoint.grpc.trace.PCustomMetricMessage)1 PDouleGaugeMetric (com.navercorp.pinpoint.grpc.trace.PDouleGaugeMetric)1 PIntCountMetric (com.navercorp.pinpoint.grpc.trace.PIntCountMetric)1 PIntGaugeMetric (com.navercorp.pinpoint.grpc.trace.PIntGaugeMetric)1 PLongCountMetric (com.navercorp.pinpoint.grpc.trace.PLongCountMetric)1 PLongGaugeMetric (com.navercorp.pinpoint.grpc.trace.PLongGaugeMetric)1 AgentCustomMetricSnapshot (com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot)1 AgentCustomMetricSnapshotBatch (com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshotBatch)1 DoubleGaugeMetricVo (com.navercorp.pinpoint.profiler.monitor.metric.custom.DoubleGaugeMetricVo)1 IntCountMetricVo (com.navercorp.pinpoint.profiler.monitor.metric.custom.IntCountMetricVo)1 IntGaugeMetricVo (com.navercorp.pinpoint.profiler.monitor.metric.custom.IntGaugeMetricVo)1 LongCountMetricVo (com.navercorp.pinpoint.profiler.monitor.metric.custom.LongCountMetricVo)1 LongGaugeMetricVo (com.navercorp.pinpoint.profiler.monitor.metric.custom.LongGaugeMetricVo)1 HashSet (java.util.HashSet)1