diff --git a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/Constants.java b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/Constants.java index 47a5b5a6b..792e38a7b 100644 --- a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/Constants.java +++ b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/Constants.java @@ -11,7 +11,8 @@ public final class Constants { private Constants() {} public static final String ONE = "1"; - public static final String KILOBYTES = "kb"; + public static final String HERTZ = "Hz"; + public static final String BYTES = "B"; public static final String MILLISECONDS = "ms"; public static final String PERCENTAGE = "%age"; public static final String READ = "read"; diff --git a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/cpu/ContextSwitchRateHandler.java b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/cpu/ContextSwitchRateHandler.java index e5507da85..64465ee12 100644 --- a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/cpu/ContextSwitchRateHandler.java +++ b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/cpu/ContextSwitchRateHandler.java @@ -5,7 +5,7 @@ package io.opentelemetry.contrib.jfr.metrics.internal.cpu; -import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.ONE; +import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.HERTZ; import io.opentelemetry.api.metrics.*; import io.opentelemetry.contrib.jfr.metrics.internal.RecordedEventHandler; @@ -28,7 +28,7 @@ public ContextSwitchRateHandler init() { otelMeter .upDownCounterBuilder(METRIC_NAME) .ofDoubles() - .setUnit(ONE) + .setUnit(HERTZ) .buildWithCallback(codm -> codm.observe(value)); return this; } diff --git a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/cpu/OverallCPULoadHandler.java b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/cpu/OverallCPULoadHandler.java index de05d8fd1..fd7f84b29 100644 --- a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/cpu/OverallCPULoadHandler.java +++ b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/cpu/OverallCPULoadHandler.java @@ -8,6 +8,7 @@ import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.ATTR_CPU_USAGE; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.MACHINE; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.ONE; +import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.PERCENTAGE; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.SYSTEM; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.USER; @@ -43,7 +44,7 @@ public OverallCPULoadHandler init() { var attr = Attributes.of(ATTR_CPU_USAGE, USER); var builder = otelMeter.histogramBuilder(METRIC_NAME); builder.setDescription(DESCRIPTION); - builder.setUnit(ONE); + builder.setUnit(PERCENTAGE); userHistogram = builder.build().bind(attr); attr = Attributes.of(ATTR_CPU_USAGE, SYSTEM); diff --git a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/GCHeapSummaryHandler.java b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/GCHeapSummaryHandler.java index ced2b9c04..9ded4594a 100644 --- a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/GCHeapSummaryHandler.java +++ b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/GCHeapSummaryHandler.java @@ -6,8 +6,8 @@ package io.opentelemetry.contrib.jfr.metrics.internal.memory; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.ATTR_MEMORY_USAGE; +import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.BYTES; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.COMMITTED; -import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.KILOBYTES; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.USED; import io.opentelemetry.api.common.Attributes; @@ -57,13 +57,13 @@ public GCHeapSummaryHandler init() { var attr = Attributes.of(ATTR_MEMORY_USAGE, USED); builder = otelMeter.histogramBuilder(METRIC_NAME_MEMORY); builder.setDescription(DESCRIPTION); - builder.setUnit(KILOBYTES); + builder.setUnit(BYTES); usedHistogram = builder.build().bind(attr); attr = Attributes.of(ATTR_MEMORY_USAGE, COMMITTED); builder = otelMeter.histogramBuilder(METRIC_NAME_MEMORY); builder.setDescription(DESCRIPTION); - builder.setUnit(KILOBYTES); + builder.setUnit(BYTES); committedHistogram = builder.build().bind(attr); return this; diff --git a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/PerThreadObjectAllocationInNewTLABHandler.java b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/PerThreadObjectAllocationInNewTLABHandler.java index c001b3986..e1760b06f 100644 --- a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/PerThreadObjectAllocationInNewTLABHandler.java +++ b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/PerThreadObjectAllocationInNewTLABHandler.java @@ -7,12 +7,12 @@ import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.ATTR_ARENA_NAME; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.ATTR_THREAD_NAME; +import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.BYTES; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.METRIC_NAME_MEMORY_ALLOCATION; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.metrics.BoundDoubleHistogram; import io.opentelemetry.api.metrics.Meter; -import io.opentelemetry.contrib.jfr.metrics.internal.Constants; import io.opentelemetry.contrib.jfr.metrics.internal.RecordedEventHandler; import jdk.jfr.consumer.RecordedEvent; @@ -35,7 +35,7 @@ public PerThreadObjectAllocationInNewTLABHandler init() { var attr = Attributes.of(ATTR_THREAD_NAME, threadName, ATTR_ARENA_NAME, TLAB); var builder = otelMeter.histogramBuilder(METRIC_NAME_MEMORY_ALLOCATION); builder.setDescription(DESCRIPTION); - builder.setUnit(Constants.KILOBYTES); + builder.setUnit(BYTES); histogram = builder.build().bind(attr); return this; } diff --git a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/PerThreadObjectAllocationOutsideTLABHandler.java b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/PerThreadObjectAllocationOutsideTLABHandler.java index 494628afd..7359b6c9e 100644 --- a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/PerThreadObjectAllocationOutsideTLABHandler.java +++ b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/memory/PerThreadObjectAllocationOutsideTLABHandler.java @@ -7,12 +7,12 @@ import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.ATTR_ARENA_NAME; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.ATTR_THREAD_NAME; +import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.BYTES; import static io.opentelemetry.contrib.jfr.metrics.internal.Constants.METRIC_NAME_MEMORY_ALLOCATION; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.metrics.BoundDoubleHistogram; import io.opentelemetry.api.metrics.Meter; -import io.opentelemetry.contrib.jfr.metrics.internal.Constants; import io.opentelemetry.contrib.jfr.metrics.internal.RecordedEventHandler; import jdk.jfr.consumer.RecordedEvent; @@ -35,7 +35,7 @@ public PerThreadObjectAllocationOutsideTLABHandler init() { var attr = Attributes.of(ATTR_THREAD_NAME, threadName, ATTR_ARENA_NAME, MAIN); var builder = otelMeter.histogramBuilder(METRIC_NAME_MEMORY_ALLOCATION); builder.setDescription(DESCRIPTION); - builder.setUnit(Constants.KILOBYTES); + builder.setUnit(BYTES); histogram = builder.build().bind(attr); return this; } diff --git a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/network/PerThreadNetworkReadHandler.java b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/network/PerThreadNetworkReadHandler.java index c36f8436c..0762c4b65 100644 --- a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/network/PerThreadNetworkReadHandler.java +++ b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/network/PerThreadNetworkReadHandler.java @@ -38,7 +38,7 @@ public PerThreadNetworkReadHandler init() { var builder = otelMeter.histogramBuilder(METRIC_NAME_BYTES); builder.setDescription(DESCRIPTION_BYTES); - builder.setUnit(Constants.KILOBYTES); + builder.setUnit(Constants.BYTES); bytesHistogram = builder.build().bind(attr); builder = otelMeter.histogramBuilder(METRIC_NAME_DURATION); diff --git a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/network/PerThreadNetworkWriteHandler.java b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/network/PerThreadNetworkWriteHandler.java index e0d8122ed..1859e9457 100644 --- a/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/network/PerThreadNetworkWriteHandler.java +++ b/jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/network/PerThreadNetworkWriteHandler.java @@ -42,7 +42,7 @@ public PerThreadNetworkWriteHandler init() { var builder = otelMeter.histogramBuilder(METRIC_NAME_BYTES); builder.setDescription(DESCRIPTION_BYTES); - builder.setUnit(Constants.KILOBYTES); + builder.setUnit(Constants.BYTES); bytesHistogram = builder.build().bind(attr); builder = otelMeter.histogramBuilder(METRIC_NAME_DURATION);