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