use of com.navercorp.pinpoint.grpc.trace.PCustomMetricMessage in project pinpoint by naver.
the class GrpcStatMessageConverter method toMessage.
@Override
public GeneratedMessageV3 toMessage(MetricType message) {
if (message instanceof AgentStatMetricSnapshotBatch) {
final AgentStatMetricSnapshotBatch agentStatMetricSnapshotBatch = (AgentStatMetricSnapshotBatch) message;
final PAgentStatBatch.Builder agentStatBatchBuilder = PAgentStatBatch.newBuilder();
// Skip agentId, startTimestamp
for (AgentStatMetricSnapshot agentStatMetricSnapshot : agentStatMetricSnapshotBatch.getAgentStats()) {
final PAgentStat agentStat = converAgentStat(agentStatMetricSnapshot);
agentStatBatchBuilder.addAgentStat(agentStat);
}
return agentStatBatchBuilder.build();
} else if (message instanceof AgentStatMetricSnapshot) {
final AgentStatMetricSnapshot agentStatMetricSnapshot = (AgentStatMetricSnapshot) message;
final PAgentStat agentStat = converAgentStat(agentStatMetricSnapshot);
return agentStat;
} else if (message instanceof AgentCustomMetricSnapshotBatch) {
final AgentCustomMetricSnapshotBatch agentCustomMetricSnapshotBatch = (AgentCustomMetricSnapshotBatch) message;
final PCustomMetricMessage pCustomMetricMessage = customMetricMessageConverter.toMessage(agentCustomMetricSnapshotBatch);
return pCustomMetricMessage;
} else if (message instanceof AgentUriStatData) {
final AgentUriStatData agentUriStatData = (AgentUriStatData) message;
final PAgentUriStat agentUriStat = uriStatMessageConverter.toMessage(agentUriStatData);
return agentUriStat;
}
return null;
}
use of com.navercorp.pinpoint.grpc.trace.PCustomMetricMessage 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