Improve MetricFetcher under concurrent conditions (#1918)
This commit is contained in:
parent
b7546c8111
commit
1f4614c0d4
|
|
@ -331,25 +331,24 @@ public class MetricFetcher {
|
||||||
* aggregation metrics by app_resource_timeSecond, ignore ip and port.
|
* aggregation metrics by app_resource_timeSecond, ignore ip and port.
|
||||||
*/
|
*/
|
||||||
String key = buildMetricKey(machine.getApp(), node.getResource(), node.getTimestamp());
|
String key = buildMetricKey(machine.getApp(), node.getResource(), node.getTimestamp());
|
||||||
MetricEntity entity = map.get(key);
|
|
||||||
if (entity != null) {
|
MetricEntity metricEntity = map.computeIfAbsent(key, s -> {
|
||||||
entity.addPassQps(node.getPassQps());
|
MetricEntity initMetricEntity = new MetricEntity();
|
||||||
entity.addBlockQps(node.getBlockQps());
|
initMetricEntity.setApp(machine.getApp());
|
||||||
entity.addRtAndSuccessQps(node.getRt(), node.getSuccessQps());
|
initMetricEntity.setTimestamp(new Date(node.getTimestamp()));
|
||||||
entity.addExceptionQps(node.getExceptionQps());
|
initMetricEntity.setPassQps(0L);
|
||||||
entity.addCount(1);
|
initMetricEntity.setBlockQps(0L);
|
||||||
} else {
|
initMetricEntity.setRtAndSuccessQps(0, 0L);
|
||||||
entity = new MetricEntity();
|
initMetricEntity.setExceptionQps(0L);
|
||||||
entity.setApp(machine.getApp());
|
initMetricEntity.setCount(0);
|
||||||
entity.setTimestamp(new Date(node.getTimestamp()));
|
initMetricEntity.setResource(node.getResource());
|
||||||
entity.setPassQps(node.getPassQps());
|
return initMetricEntity;
|
||||||
entity.setBlockQps(node.getBlockQps());
|
});
|
||||||
entity.setRtAndSuccessQps(node.getRt(), node.getSuccessQps());
|
metricEntity.addPassQps(node.getPassQps());
|
||||||
entity.setExceptionQps(node.getExceptionQps());
|
metricEntity.addBlockQps(node.getBlockQps());
|
||||||
entity.setCount(1);
|
metricEntity.addRtAndSuccessQps(node.getRt(), node.getSuccessQps());
|
||||||
entity.setResource(node.getResource());
|
metricEntity.addExceptionQps(node.getExceptionQps());
|
||||||
map.put(key, entity);
|
metricEntity.addCount(1);
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("handleBody line exception, machine: {}, line: {}", machine.toLogString(), line);
|
logger.warn("handleBody line exception, machine: {}, line: {}", machine.toLogString(), line);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue