Skip to content

Commit a0796c6

Browse files
committed
follow Prometheus naming conventions for new metric names
1 parent 96ce10f commit a0796c6

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/MemoryPoolsExports.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ void addMemoryAreaMetrics(List<MetricFamilySamples> sampleFamilies) {
8888
}
8989

9090
void addMemoryPoolMetrics(List<MetricFamilySamples> sampleFamilies) {
91+
92+
// Note: The Prometheus naming convention is that units belong at the end of the metric name.
93+
// For new metrics like jvm_memory_pool_collection_used_bytes we follow that convention.
94+
// For old metrics like jvm_memory_pool_bytes_used we keep the names as they are to avoid a breaking change.
95+
9196
GaugeMetricFamily used = new GaugeMetricFamily(
9297
"jvm_memory_pool_bytes_used",
9398
"Used bytes of a given JVM memory pool.",
@@ -109,22 +114,22 @@ void addMemoryPoolMetrics(List<MetricFamilySamples> sampleFamilies) {
109114
Collections.singletonList("pool"));
110115
sampleFamilies.add(init);
111116
GaugeMetricFamily collectionUsed = new GaugeMetricFamily(
112-
"jvm_memory_pool_collection_bytes_used",
117+
"jvm_memory_pool_collection_used_bytes",
113118
"Used bytes after last collection of a given JVM memory pool.",
114119
Collections.singletonList("pool"));
115120
sampleFamilies.add(collectionUsed);
116121
GaugeMetricFamily collectionCommitted = new GaugeMetricFamily(
117-
"jvm_memory_pool_collection_bytes_committed",
122+
"jvm_memory_pool_collection_committed_bytes",
118123
"Committed after last collection bytes of a given JVM memory pool.",
119124
Collections.singletonList("pool"));
120125
sampleFamilies.add(collectionCommitted);
121126
GaugeMetricFamily collectionMax = new GaugeMetricFamily(
122-
"jvm_memory_pool_collection_bytes_max",
127+
"jvm_memory_pool_collection_max_bytes",
123128
"Max bytes after last collection of a given JVM memory pool.",
124129
Collections.singletonList("pool"));
125130
sampleFamilies.add(collectionMax);
126131
GaugeMetricFamily collectionInit = new GaugeMetricFamily(
127-
"jvm_memory_pool_collection_bytes_init",
132+
"jvm_memory_pool_collection_init_bytes",
128133
"Initial after last collection bytes of a given JVM memory pool.",
129134
Collections.singletonList("pool"));
130135
sampleFamilies.add(collectionInit);

simpleclient_hotspot/src/test/java/io/prometheus/client/hotspot/MemoryPoolsExportsTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,28 @@ public void testMemoryPools() {
9090
assertEquals(
9191
400000L,
9292
registry.getSampleValue(
93-
"jvm_memory_pool_collection_bytes_used",
93+
"jvm_memory_pool_collection_used_bytes",
9494
new String[]{"pool"},
9595
new String[]{"PS Eden Space"}),
9696
.0000001);
9797
assertEquals(
9898
800000L,
9999
registry.getSampleValue(
100-
"jvm_memory_pool_collection_bytes_committed",
100+
"jvm_memory_pool_collection_committed_bytes",
101101
new String[]{"pool"},
102102
new String[]{"PS Eden Space"}),
103103
.0000001);
104104
assertEquals(
105105
1600000L,
106106
registry.getSampleValue(
107-
"jvm_memory_pool_collection_bytes_max",
107+
"jvm_memory_pool_collection_max_bytes",
108108
new String[]{"pool"},
109109
new String[]{"PS Eden Space"}),
110110
.0000001);
111111
assertEquals(
112112
2000L,
113113
registry.getSampleValue(
114-
"jvm_memory_pool_collection_bytes_init",
114+
"jvm_memory_pool_collection_init_bytes",
115115
new String[]{"pool"},
116116
new String[]{"PS Eden Space"}),
117117
.0000001);
@@ -146,28 +146,28 @@ public void testMemoryPools() {
146146
assertEquals(
147147
20000L,
148148
registry.getSampleValue(
149-
"jvm_memory_pool_collection_bytes_used",
149+
"jvm_memory_pool_collection_used_bytes",
150150
new String[]{"pool"},
151151
new String[]{"PS Old Gen"}),
152152
.0000001);
153153
assertEquals(
154154
40000L,
155155
registry.getSampleValue(
156-
"jvm_memory_pool_collection_bytes_committed",
156+
"jvm_memory_pool_collection_committed_bytes",
157157
new String[]{"pool"},
158158
new String[]{"PS Old Gen"}),
159159
.0000001);
160160
assertEquals(
161161
6000000L,
162162
registry.getSampleValue(
163-
"jvm_memory_pool_collection_bytes_max",
163+
"jvm_memory_pool_collection_max_bytes",
164164
new String[]{"pool"},
165165
new String[]{"PS Old Gen"}),
166166
.0000001);
167167
assertEquals(
168168
4000L,
169169
registry.getSampleValue(
170-
"jvm_memory_pool_collection_bytes_init",
170+
"jvm_memory_pool_collection_init_bytes",
171171
new String[]{"pool"},
172172
new String[]{"PS Old Gen"}),
173173
.0000001);

0 commit comments

Comments
 (0)