File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
main/java/io/prometheus/client/hotspot
test/java/io/prometheus/client/hotspot Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ void addMemoryAreaMetrics(List<MetricFamilySamples> sampleFamilies) {
4848 MemoryUsage heapUsage = memoryBean .getHeapMemoryUsage ();
4949 MemoryUsage nonHeapUsage = memoryBean .getNonHeapMemoryUsage ();
5050
51+ GaugeMetricFamily finalizer = new GaugeMetricFamily (
52+ "jvm_objects_pending_finalization" ,
53+ "The number of objects waiting in the finalizer queue." ,
54+ memoryBean .getObjectPendingFinalizationCount ());
55+ sampleFamilies .add (finalizer );
56+
5157 GaugeMetricFamily used = new GaugeMetricFamily (
5258 "jvm_memory_bytes_used" ,
5359 "Used bytes of a given JVM memory area." ,
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ public void setUp() {
3535 when (mockPoolsBean2 .getName ()).thenReturn ("PS Old Gen" );
3636 when (mockPoolsBean2 .getUsage ()).thenReturn (mockUsage2 );
3737 when (mockPoolsBean2 .getCollectionUsage ()).thenReturn (mockCollectionUsage2 );
38+ when (mockMemoryBean .getObjectPendingFinalizationCount ()).thenReturn (10 );
3839 when (mockMemoryBean .getHeapMemoryUsage ()).thenReturn (mockUsage1 );
3940 when (mockMemoryBean .getNonHeapMemoryUsage ()).thenReturn (mockUsage2 );
4041 when (mockUsage1 .getUsed ()).thenReturn (500000L );
@@ -174,6 +175,11 @@ public void testMemoryPools() {
174175
175176 @ Test
176177 public void testMemoryAreas () {
178+ assertEquals (
179+ 10L ,
180+ registry .getSampleValue (
181+ "jvm_objects_pending_finalization" ),
182+ .0000001 );
177183 assertEquals (
178184 500000L ,
179185 registry .getSampleValue (
You can’t perform that action at this time.
0 commit comments