Search in sources :

Example 1 with AgentCustomMetricSnapshot

use of com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot in project pinpoint by naver.

the class GrpcCustomMetricMessageConverter method create.

private PCustomMetric create(String metricName, List<AgentCustomMetricSnapshot> agentCustomMetricSnapshotList) {
    int size = agentCustomMetricSnapshotList.size();
    CustomMetricVo representativeCustomMetricVo = null;
    CustomMetricVo[] customMetricVos = new CustomMetricVo[size];
    for (int i = 0; i < size; i++) {
        AgentCustomMetricSnapshot agentCustomMetricSnapshot = agentCustomMetricSnapshotList.get(i);
        CustomMetricVo customMetricVo = agentCustomMetricSnapshot.get(metricName);
        customMetricVos[i] = customMetricVo;
        if (customMetricVo == null) {
            continue;
        }
        if (representativeCustomMetricVo == null) {
            representativeCustomMetricVo = customMetricVo;
        }
    }
    return create0(metricName, representativeCustomMetricVo, customMetricVos);
}
Also used : AgentCustomMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot) CustomMetricVo(com.navercorp.pinpoint.profiler.monitor.metric.custom.CustomMetricVo)

Example 2 with AgentCustomMetricSnapshot

use of com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot in project pinpoint by naver.

the class CustomMetricCollectingJob method run.

@Override
public void run() {
    final long currentCollectionTimestamp = System.currentTimeMillis();
    final long collectInterval = currentCollectionTimestamp - this.prevCollectionTimestamp;
    try {
        final AgentCustomMetricSnapshot agentCustomMetricSnapshot = agentCustomMetricCollector.collect();
        agentCustomMetricSnapshot.setTimestamp(currentCollectionTimestamp);
        agentCustomMetricSnapshot.setCollectInterval(collectInterval);
        this.agentCustomMetricSnapshotList.add(agentCustomMetricSnapshot);
        if (++this.collectCount >= numCollectionsPerBatch) {
            send();
            this.collectCount = 0;
        }
    } catch (Exception ex) {
        logger.warn("CustomMetric collect failed. Caused:{}", ex.getMessage(), ex);
    } finally {
        this.prevCollectionTimestamp = currentCollectionTimestamp;
    }
}
Also used : AgentCustomMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot)

Example 3 with AgentCustomMetricSnapshot

use of com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot in project pinpoint by naver.

the class CustomMetricCollectingJob method send.

private void send() {
    final AgentCustomMetricSnapshotBatch agentCustomMetricSnapshotBatch = new AgentCustomMetricSnapshotBatch(agentCustomMetricSnapshotList);
    logger.trace("collect agentCustomMetric:{}", agentCustomMetricSnapshotBatch);
    dataSender.send(agentCustomMetricSnapshotBatch);
    this.agentCustomMetricSnapshotList = new ArrayList<AgentCustomMetricSnapshot>(numCollectionsPerBatch);
}
Also used : AgentCustomMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot) AgentCustomMetricSnapshotBatch(com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshotBatch)

Example 4 with AgentCustomMetricSnapshot

use of com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot 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)

Example 5 with AgentCustomMetricSnapshot

use of com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot in project pinpoint by naver.

the class AgentCustomMetricCollector method collect.

public AgentCustomMetricSnapshot collect() {
    Map<String, CustomMetricWrapper> customMetricMap = customMetricRegistryService.getCustomMetricMap();
    int size = customMetricMap.size();
    AgentCustomMetricSnapshot agentCustomMetricSnapshot = new AgentCustomMetricSnapshot(size);
    for (CustomMetricWrapper metricWrapper : customMetricMap.values()) {
        agentCustomMetricSnapshot.add(metricWrapper.snapshot());
    }
    return agentCustomMetricSnapshot;
}
Also used : AgentCustomMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot) CustomMetricWrapper(com.navercorp.pinpoint.profiler.context.monitor.metric.CustomMetricWrapper)

Aggregations

AgentCustomMetricSnapshot (com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshot)5 AgentCustomMetricSnapshotBatch (com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshotBatch)2 PCustomMetric (com.navercorp.pinpoint.grpc.trace.PCustomMetric)1 PCustomMetricMessage (com.navercorp.pinpoint.grpc.trace.PCustomMetricMessage)1 CustomMetricWrapper (com.navercorp.pinpoint.profiler.context.monitor.metric.CustomMetricWrapper)1 CustomMetricVo (com.navercorp.pinpoint.profiler.monitor.metric.custom.CustomMetricVo)1 HashSet (java.util.HashSet)1