Skip to content

Commit

Permalink
follow Prometheus naming conventions for new metric names
Browse files Browse the repository at this point in the history
  • Loading branch information
fstab committed May 30, 2021
1 parent 96ce10f commit a0796c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ void addMemoryAreaMetrics(List<MetricFamilySamples> sampleFamilies) {
}

void addMemoryPoolMetrics(List<MetricFamilySamples> 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.",
Expand All @@ -109,22 +114,22 @@ void addMemoryPoolMetrics(List<MetricFamilySamples> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a0796c6

Please sign in to comment.