Fix some gauge types (#4962)

This commit is contained in:
Anuraag Agrawal 2021-12-22 05:40:13 +09:00 committed by GitHub
parent 0fd7b8baa0
commit a9aee8ed45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 24 deletions

View File

@ -28,8 +28,7 @@ public class ProcessMetrics {
OSProcess processInfo = osInfo.getProcess(osInfo.getProcessId()); OSProcess processInfo = osInfo.getProcess(osInfo.getProcessId());
meter meter
.gaugeBuilder("runtime.java.memory") .upDownCounterBuilder("runtime.java.memory")
.ofLongs()
.setDescription("Runtime Java memory") .setDescription("Runtime Java memory")
.setUnit("bytes") .setUnit("bytes")
.buildWithCallback( .buildWithCallback(

View File

@ -36,8 +36,7 @@ public class SystemMetrics {
HardwareAbstractionLayer hal = systemInfo.getHardware(); HardwareAbstractionLayer hal = systemInfo.getHardware();
meter meter
.gaugeBuilder("system.memory.usage") .upDownCounterBuilder("system.memory.usage")
.ofLongs()
.setDescription("System memory usage") .setDescription("System memory usage")
.setUnit("By") .setUnit("By")
.buildWithCallback( .buildWithCallback(
@ -61,8 +60,7 @@ public class SystemMetrics {
}); });
meter meter
.gaugeBuilder("system.network.io") .counterBuilder("system.network.io")
.ofLongs()
.setDescription("System network IO") .setDescription("System network IO")
.setUnit("By") .setUnit("By")
.buildWithCallback( .buildWithCallback(
@ -78,8 +76,7 @@ public class SystemMetrics {
}); });
meter meter
.gaugeBuilder("system.network.packets") .counterBuilder("system.network.packets")
.ofLongs()
.setDescription("System network packets") .setDescription("System network packets")
.setUnit("packets") .setUnit("packets")
.buildWithCallback( .buildWithCallback(
@ -95,8 +92,7 @@ public class SystemMetrics {
}); });
meter meter
.gaugeBuilder("system.network.errors") .counterBuilder("system.network.errors")
.ofLongs()
.setDescription("System network errors") .setDescription("System network errors")
.setUnit("errors") .setUnit("errors")
.buildWithCallback( .buildWithCallback(
@ -112,8 +108,7 @@ public class SystemMetrics {
}); });
meter meter
.gaugeBuilder("system.disk.io") .counterBuilder("system.disk.io")
.ofLongs()
.setDescription("System disk IO") .setDescription("System disk IO")
.setUnit("By") .setUnit("By")
.buildWithCallback( .buildWithCallback(
@ -128,8 +123,7 @@ public class SystemMetrics {
}); });
meter meter
.gaugeBuilder("system.disk.operations") .counterBuilder("system.disk.operations")
.ofLongs()
.setDescription("System disk operations") .setDescription("System disk operations")
.setUnit("operations") .setUnit("operations")
.buildWithCallback( .buildWithCallback(

View File

@ -20,7 +20,7 @@ public class ProcessMetricsTest extends AbstractMetricsTest {
metric metric
.hasName("runtime.java.memory") .hasName("runtime.java.memory")
.hasUnit("bytes") .hasUnit("bytes")
.hasLongGauge() .hasLongSum()
.points() .points()
.anySatisfy(point -> assertThat(point.getValue()).isPositive()), .anySatisfy(point -> assertThat(point.getValue()).isPositive()),
metric -> metric ->

View File

@ -20,7 +20,7 @@ public class SystemMetricsTest extends AbstractMetricsTest {
metric metric
.hasName("system.memory.usage") .hasName("system.memory.usage")
.hasUnit("By") .hasUnit("By")
.hasLongGauge() .hasLongSum()
.points() .points()
.anySatisfy(point -> assertThat(point.getValue()).isPositive()), .anySatisfy(point -> assertThat(point.getValue()).isPositive()),
metric -> metric ->
@ -30,9 +30,9 @@ public class SystemMetricsTest extends AbstractMetricsTest {
.hasDoubleGauge() .hasDoubleGauge()
.points() .points()
.anySatisfy(point -> assertThat(point.getValue()).isPositive()), .anySatisfy(point -> assertThat(point.getValue()).isPositive()),
metric -> metric.hasName("system.network.io").hasUnit("By").hasLongGauge(), metric -> metric.hasName("system.network.io").hasUnit("By").hasLongSum(),
metric -> metric.hasName("system.network.packets").hasUnit("packets").hasLongGauge(), metric -> metric.hasName("system.network.packets").hasUnit("packets").hasLongSum(),
metric -> metric.hasName("system.network.errors").hasUnit("errors").hasLongGauge(), metric -> metric.hasName("system.network.errors").hasUnit("errors").hasLongSum(),
metric -> metric.hasName("system.disk.operations").hasUnit("operations").hasLongGauge()); metric -> metric.hasName("system.disk.operations").hasUnit("operations").hasLongSum());
} }
} }

View File

@ -63,8 +63,7 @@ public final class MemoryPools {
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
Meter meter = GlobalOpenTelemetry.get().getMeterProvider().get(MemoryPools.class.getName()); Meter meter = GlobalOpenTelemetry.get().getMeterProvider().get(MemoryPools.class.getName());
meter meter
.gaugeBuilder("runtime.jvm.memory.area") .upDownCounterBuilder("runtime.jvm.memory.area")
.ofLongs()
.setDescription("Bytes of a given JVM memory area.") .setDescription("Bytes of a given JVM memory area.")
.setUnit("By") .setUnit("By")
.buildWithCallback( .buildWithCallback(
@ -88,8 +87,7 @@ public final class MemoryPools {
maxLabelSets.add(Attributes.of(TYPE_KEY, MAX, POOL_KEY, pool.getName())); maxLabelSets.add(Attributes.of(TYPE_KEY, MAX, POOL_KEY, pool.getName()));
} }
meter meter
.gaugeBuilder("runtime.jvm.memory.pool") .upDownCounterBuilder("runtime.jvm.memory.pool")
.ofLongs()
.setDescription("Bytes of a given JVM memory pool.") .setDescription("Bytes of a given JVM memory pool.")
.setUnit("By") .setUnit("By")
.buildWithCallback( .buildWithCallback(