Add runtime.jvm.gc.collection.count metric (#2616)
* Add runtime.jvm.gc.collection.count metric
* Fix format violation
* Rename gc.collection to gc.collection.time
* Another rename 😅
This commit is contained in:
parent
4168c0b4fe
commit
56c52bc315
|
@ -16,7 +16,8 @@ class RuntimeMetricsTest extends AgentInstrumentationSpecification {
|
|||
|
||||
then:
|
||||
conditions.eventually {
|
||||
assert getMetrics().any { it.name == "runtime.jvm.gc.collection" }
|
||||
assert getMetrics().any { it.name == "runtime.jvm.gc.time" }
|
||||
assert getMetrics().any { it.name == "runtime.jvm.gc.count" }
|
||||
assert getMetrics().any { it.name == "runtime.jvm.memory.area" }
|
||||
assert getMetrics().any { it.name == "runtime.jvm.memory.pool" }
|
||||
}
|
||||
|
|
|
@ -25,7 +25,8 @@ import java.util.List;
|
|||
* <p>Example metrics being exported:
|
||||
*
|
||||
* <pre>
|
||||
* runtime.jvm.gc.collection{gc="PS1"} 6.7
|
||||
* runtime.jvm.gc.time{gc="PS1"} 6.7
|
||||
* runtime.jvm.gc.count{gc="PS1"} 1
|
||||
* </pre>
|
||||
*/
|
||||
public final class GarbageCollector {
|
||||
|
@ -40,7 +41,7 @@ public final class GarbageCollector {
|
|||
labelSets.add(Labels.of(GC_LABEL_KEY, gc.getName()));
|
||||
}
|
||||
meter
|
||||
.longSumObserverBuilder("runtime.jvm.gc.collection")
|
||||
.longSumObserverBuilder("runtime.jvm.gc.time")
|
||||
.setDescription("Time spent in a given JVM garbage collector in milliseconds.")
|
||||
.setUnit("ms")
|
||||
.setUpdater(
|
||||
|
@ -51,6 +52,19 @@ public final class GarbageCollector {
|
|||
}
|
||||
})
|
||||
.build();
|
||||
meter
|
||||
.longSumObserverBuilder("runtime.jvm.gc.count")
|
||||
.setDescription(
|
||||
"The number of collections that have occurred for a given JVM garbage collector.")
|
||||
.setUnit("collections")
|
||||
.setUpdater(
|
||||
resultLongObserver -> {
|
||||
for (int i = 0; i < garbageCollectors.size(); i++) {
|
||||
resultLongObserver.observe(
|
||||
garbageCollectors.get(i).getCollectionCount(), labelSets.get(i));
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
private GarbageCollector() {}
|
||||
|
|
|
@ -62,7 +62,8 @@ class SpringBootSmokeTest extends SmokeTest {
|
|||
|
||||
then: "JVM metrics are exported"
|
||||
def metrics = new MetricsInspector(waitForMetrics())
|
||||
metrics.hasMetricsNamed("runtime.jvm.gc.collection")
|
||||
metrics.hasMetricsNamed("runtime.jvm.gc.time")
|
||||
metrics.hasMetricsNamed("runtime.jvm.gc.count")
|
||||
metrics.hasMetricsNamed("runtime.jvm.memory.area")
|
||||
metrics.hasMetricsNamed("runtime.jvm.memory.pool")
|
||||
|
||||
|
|
Loading…
Reference in New Issue