Skip to content

Commit c3af284

Browse files
committed
修改2.0.x 版本metrics节点null指针问题
1 parent 73fa4e6 commit c3af284

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

moss-client/moss-client-2.x/src/main/java/org/xujin/moss/client/endpoint/MossMetricsEndpoint.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,18 @@ public HaloMetricResponse HaloMetric() {
5353
haloMetricResponse.setJvmMemoryUsedHeap(String.valueOf(jvmNemoryUsedHeap.getMeasurements().get(0).getValue()));
5454
MetricResponse jvmNemoryUsedNonHeap=metric("jvm.memory.used", Arrays.asList("area:nonheap") );
5555
haloMetricResponse.setJvmMemoryUsedNonHeap(String.valueOf(jvmNemoryUsedNonHeap.getMeasurements().get(0).getValue()));
56-
56+
// 2.0 actuator/metrics 中没有这个key
5757
MetricResponse systemLoadAverage=metric("system.load.average.1m", null );
58-
haloMetricResponse.setSystemloadAverage(String.valueOf(systemLoadAverage.getMeasurements().get(0).getValue()));
59-
58+
if(systemLoadAverage!=null){
59+
haloMetricResponse.setSystemloadAverage(String.valueOf(systemLoadAverage.getMeasurements().get(0).getValue()));
60+
}
6061
MetricResponse heapCommitted=metric("jvm.memory.committed", Arrays.asList("area:heap") );
6162
haloMetricResponse.setHeapCommitted(String.valueOf(heapCommitted.getMeasurements().get(0).getValue()));
6263
MetricResponse nonheapCommitted=metric("jvm.memory.committed", Arrays.asList("area:nonheap") );
6364
haloMetricResponse.setNonheapCommitted(String.valueOf(nonheapCommitted.getMeasurements().get(0).getValue()));
6465

6566
MetricResponse heapMax=metric("jvm.memory.max", Arrays.asList("area:heap") );
6667
haloMetricResponse.setHeapMax(String.valueOf(heapMax.getMeasurements().get(0).getValue()));
67-
68-
6968
getGcinfo(haloMetricResponse);
7069
MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean()
7170
.getHeapMemoryUsage();

0 commit comments

Comments
 (0)