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);
}
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;
}
}
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);
}
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());
}
}
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;
}
Aggregations