From a0796c6ca3d5f068d2b2e9551318cb0e4fd41cb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20St=C3=A4ber?= Date: Sun, 30 May 2021 13:29:06 +0200 Subject: [PATCH] follow Prometheus naming conventions for new metric names --- .../client/hotspot/MemoryPoolsExports.java | 13 +++++++++---- .../client/hotspot/MemoryPoolsExportsTest.java | 16 ++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/MemoryPoolsExports.java b/simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/MemoryPoolsExports.java index 5a1ff07b2..0b37e72ba 100644 --- a/simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/MemoryPoolsExports.java +++ b/simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/MemoryPoolsExports.java @@ -88,6 +88,11 @@ void addMemoryAreaMetrics(List sampleFamilies) { } void addMemoryPoolMetrics(List sampleFamilies) { + + // Note: The Prometheus naming convention is that units belong at the end of the metric name. + // For new metrics like jvm_memory_pool_collection_used_bytes we follow that convention. + // For old metrics like jvm_memory_pool_bytes_used we keep the names as they are to avoid a breaking change. + GaugeMetricFamily used = new GaugeMetricFamily( "jvm_memory_pool_bytes_used", "Used bytes of a given JVM memory pool.", @@ -109,22 +114,22 @@ void addMemoryPoolMetrics(List sampleFamilies) { Collections.singletonList("pool")); sampleFamilies.add(init); GaugeMetricFamily collectionUsed = new GaugeMetricFamily( - "jvm_memory_pool_collection_bytes_used", + "jvm_memory_pool_collection_used_bytes", "Used bytes after last collection of a given JVM memory pool.", Collections.singletonList("pool")); sampleFamilies.add(collectionUsed); GaugeMetricFamily collectionCommitted = new GaugeMetricFamily( - "jvm_memory_pool_collection_bytes_committed", + "jvm_memory_pool_collection_committed_bytes", "Committed after last collection bytes of a given JVM memory pool.", Collections.singletonList("pool")); sampleFamilies.add(collectionCommitted); GaugeMetricFamily collectionMax = new GaugeMetricFamily( - "jvm_memory_pool_collection_bytes_max", + "jvm_memory_pool_collection_max_bytes", "Max bytes after last collection of a given JVM memory pool.", Collections.singletonList("pool")); sampleFamilies.add(collectionMax); GaugeMetricFamily collectionInit = new GaugeMetricFamily( - "jvm_memory_pool_collection_bytes_init", + "jvm_memory_pool_collection_init_bytes", "Initial after last collection bytes of a given JVM memory pool.", Collections.singletonList("pool")); sampleFamilies.add(collectionInit); diff --git a/simpleclient_hotspot/src/test/java/io/prometheus/client/hotspot/MemoryPoolsExportsTest.java b/simpleclient_hotspot/src/test/java/io/prometheus/client/hotspot/MemoryPoolsExportsTest.java index 5b300bfed..613b16708 100644 --- a/simpleclient_hotspot/src/test/java/io/prometheus/client/hotspot/MemoryPoolsExportsTest.java +++ b/simpleclient_hotspot/src/test/java/io/prometheus/client/hotspot/MemoryPoolsExportsTest.java @@ -90,28 +90,28 @@ public void testMemoryPools() { assertEquals( 400000L, registry.getSampleValue( - "jvm_memory_pool_collection_bytes_used", + "jvm_memory_pool_collection_used_bytes", new String[]{"pool"}, new String[]{"PS Eden Space"}), .0000001); assertEquals( 800000L, registry.getSampleValue( - "jvm_memory_pool_collection_bytes_committed", + "jvm_memory_pool_collection_committed_bytes", new String[]{"pool"}, new String[]{"PS Eden Space"}), .0000001); assertEquals( 1600000L, registry.getSampleValue( - "jvm_memory_pool_collection_bytes_max", + "jvm_memory_pool_collection_max_bytes", new String[]{"pool"}, new String[]{"PS Eden Space"}), .0000001); assertEquals( 2000L, registry.getSampleValue( - "jvm_memory_pool_collection_bytes_init", + "jvm_memory_pool_collection_init_bytes", new String[]{"pool"}, new String[]{"PS Eden Space"}), .0000001); @@ -146,28 +146,28 @@ public void testMemoryPools() { assertEquals( 20000L, registry.getSampleValue( - "jvm_memory_pool_collection_bytes_used", + "jvm_memory_pool_collection_used_bytes", new String[]{"pool"}, new String[]{"PS Old Gen"}), .0000001); assertEquals( 40000L, registry.getSampleValue( - "jvm_memory_pool_collection_bytes_committed", + "jvm_memory_pool_collection_committed_bytes", new String[]{"pool"}, new String[]{"PS Old Gen"}), .0000001); assertEquals( 6000000L, registry.getSampleValue( - "jvm_memory_pool_collection_bytes_max", + "jvm_memory_pool_collection_max_bytes", new String[]{"pool"}, new String[]{"PS Old Gen"}), .0000001); assertEquals( 4000L, registry.getSampleValue( - "jvm_memory_pool_collection_bytes_init", + "jvm_memory_pool_collection_init_bytes", new String[]{"pool"}, new String[]{"PS Old Gen"}), .0000001);