From f528e9fe12e8afff52bfaa69f9ae57c1582b3aa3 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Tue, 21 Dec 2021 05:04:11 +0000 Subject: [PATCH] Fix some gauge types --- .../instrumentation/oshi/ProcessMetrics.java | 3 +-- .../instrumentation/oshi/SystemMetrics.java | 18 ++++++------------ .../oshi/ProcessMetricsTest.java | 2 +- .../oshi/SystemMetricsTest.java | 10 +++++----- .../runtimemetrics/MemoryPools.java | 6 ++---- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/ProcessMetrics.java b/instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/ProcessMetrics.java index 2c4ce204651c..0c190e8426ca 100644 --- a/instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/ProcessMetrics.java +++ b/instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/ProcessMetrics.java @@ -28,8 +28,7 @@ public static void registerObservers() { OSProcess processInfo = osInfo.getProcess(osInfo.getProcessId()); meter - .gaugeBuilder("runtime.java.memory") - .ofLongs() + .upDownCounterBuilder("runtime.java.memory") .setDescription("Runtime Java memory") .setUnit("bytes") .buildWithCallback( diff --git a/instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/SystemMetrics.java b/instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/SystemMetrics.java index 2b575b5f735a..e6ef00e0308b 100644 --- a/instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/SystemMetrics.java +++ b/instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/SystemMetrics.java @@ -36,8 +36,7 @@ public static void registerObservers() { HardwareAbstractionLayer hal = systemInfo.getHardware(); meter - .gaugeBuilder("system.memory.usage") - .ofLongs() + .upDownCounterBuilder("system.memory.usage") .setDescription("System memory usage") .setUnit("By") .buildWithCallback( @@ -61,8 +60,7 @@ public static void registerObservers() { }); meter - .gaugeBuilder("system.network.io") - .ofLongs() + .counterBuilder("system.network.io") .setDescription("System network IO") .setUnit("By") .buildWithCallback( @@ -78,8 +76,7 @@ public static void registerObservers() { }); meter - .gaugeBuilder("system.network.packets") - .ofLongs() + .counterBuilder("system.network.packets") .setDescription("System network packets") .setUnit("packets") .buildWithCallback( @@ -95,8 +92,7 @@ public static void registerObservers() { }); meter - .gaugeBuilder("system.network.errors") - .ofLongs() + .counterBuilder("system.network.errors") .setDescription("System network errors") .setUnit("errors") .buildWithCallback( @@ -112,8 +108,7 @@ public static void registerObservers() { }); meter - .gaugeBuilder("system.disk.io") - .ofLongs() + .counterBuilder("system.disk.io") .setDescription("System disk IO") .setUnit("By") .buildWithCallback( @@ -128,8 +123,7 @@ public static void registerObservers() { }); meter - .gaugeBuilder("system.disk.operations") - .ofLongs() + .counterBuilder("system.disk.operations") .setDescription("System disk operations") .setUnit("operations") .buildWithCallback( diff --git a/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/ProcessMetricsTest.java b/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/ProcessMetricsTest.java index 62517d0b9a29..67d32d532153 100644 --- a/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/ProcessMetricsTest.java +++ b/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/ProcessMetricsTest.java @@ -20,7 +20,7 @@ public void test() { metric .hasName("runtime.java.memory") .hasUnit("bytes") - .hasLongGauge() + .hasLongSum() .points() .anySatisfy(point -> assertThat(point.getValue()).isPositive()), metric -> diff --git a/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/SystemMetricsTest.java b/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/SystemMetricsTest.java index 4196aedddc84..16c127877697 100644 --- a/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/SystemMetricsTest.java +++ b/instrumentation/oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/SystemMetricsTest.java @@ -20,7 +20,7 @@ public void test() { metric .hasName("system.memory.usage") .hasUnit("By") - .hasLongGauge() + .hasLongSum() .points() .anySatisfy(point -> assertThat(point.getValue()).isPositive()), metric -> @@ -30,9 +30,9 @@ public void test() { .hasDoubleGauge() .points() .anySatisfy(point -> assertThat(point.getValue()).isPositive()), - metric -> metric.hasName("system.network.io").hasUnit("By").hasLongGauge(), - metric -> metric.hasName("system.network.packets").hasUnit("packets").hasLongGauge(), - metric -> metric.hasName("system.network.errors").hasUnit("errors").hasLongGauge(), - metric -> metric.hasName("system.disk.operations").hasUnit("operations").hasLongGauge()); + metric -> metric.hasName("system.network.io").hasUnit("By").hasLongSum(), + metric -> metric.hasName("system.network.packets").hasUnit("packets").hasLongSum(), + metric -> metric.hasName("system.network.errors").hasUnit("errors").hasLongSum(), + metric -> metric.hasName("system.disk.operations").hasUnit("operations").hasLongSum()); } } diff --git a/instrumentation/runtime-metrics/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/MemoryPools.java b/instrumentation/runtime-metrics/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/MemoryPools.java index 9f06f5d05b88..bc64e7935960 100644 --- a/instrumentation/runtime-metrics/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/MemoryPools.java +++ b/instrumentation/runtime-metrics/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/MemoryPools.java @@ -63,8 +63,7 @@ public static void registerMemoryAreaObservers() { MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); Meter meter = GlobalOpenTelemetry.get().getMeterProvider().get(MemoryPools.class.getName()); meter - .gaugeBuilder("runtime.jvm.memory.area") - .ofLongs() + .upDownCounterBuilder("runtime.jvm.memory.area") .setDescription("Bytes of a given JVM memory area.") .setUnit("By") .buildWithCallback( @@ -88,8 +87,7 @@ public static void registerMemoryPoolObservers() { maxLabelSets.add(Attributes.of(TYPE_KEY, MAX, POOL_KEY, pool.getName())); } meter - .gaugeBuilder("runtime.jvm.memory.pool") - .ofLongs() + .upDownCounterBuilder("runtime.jvm.memory.pool") .setDescription("Bytes of a given JVM memory pool.") .setUnit("By") .buildWithCallback(