Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace "1" with the appropriate units #8668

Merged
merged 9 commits into from
Jun 14, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static String description(Meter.Id id) {

static String baseUnit(Meter.Id id) {
String baseUnit = id.getBaseUnit();
return baseUnit == null ? "1" : baseUnit;
return baseUnit == null ? "" : baseUnit;
}

static String statisticInstrumentName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class OpenTelemetryFunctionTimer<T> extends AbstractMeter
otelMeter
.counterBuilder(name + ".count")
.setDescription(Bridging.description(id))
.setUnit("1")
.setUnit("{invocation}")
.buildWithCallback(new LongMeasurementRecorder<>(obj, countFunction, attributes));

this.observableTotalTime =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void testFunctionTimerWithBaseUnitMilliseconds() {
metric ->
assertThat(metric)
.hasDescription("This is a test function timer")
.hasUnit("1")
.hasUnit("{invocation}")
.hasLongSumSatisfying(
sum ->
sum.isMonotonic()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void testFunctionTimer() {
metric ->
assertThat(metric)
.hasDescription("This is a test function timer")
.hasUnit("1")
.hasUnit("{invocation}")
.hasLongSumSatisfying(
sum ->
sum.isMonotonic()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void testFunctionTimer() {
metric ->
assertThat(metric)
.hasDescription("This is a test function timer")
.hasUnit("1")
.hasUnit("{invocation}")
.hasLongSumSatisfying(
sum ->
sum.isMonotonic()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ List<AutoCloseable> registerObservers(OpenTelemetry openTelemetry, ClassLoadingM
meter
.counterBuilder("process.runtime.jvm.classes.loaded")
.setDescription("Number of classes loaded since JVM start")
.setUnit("1")
.setUnit("{class}")
.buildWithCallback(
observableMeasurement ->
observableMeasurement.record(classBean.getTotalLoadedClassCount())));
Expand All @@ -57,15 +57,15 @@ List<AutoCloseable> registerObservers(OpenTelemetry openTelemetry, ClassLoadingM
meter
.counterBuilder("process.runtime.jvm.classes.unloaded")
.setDescription("Number of classes unloaded since JVM start")
.setUnit("1")
.setUnit("{class}")
.buildWithCallback(
observableMeasurement ->
observableMeasurement.record(classBean.getUnloadedClassCount())));
observables.add(
meter
.upDownCounterBuilder("process.runtime.jvm.classes.current_loaded")
.setDescription("Number of classes currently loaded")
.setUnit("1")
.setUnit("{class}")
.buildWithCallback(
observableMeasurement ->
observableMeasurement.record(classBean.getLoadedClassCount())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ List<AutoCloseable> registerObservers(
meter
.gaugeBuilder("process.runtime.jvm.system.cpu.load_1m")
.setDescription("Average CPU load of the whole system for the last minute")
.setUnit("1")
.setUnit("{run_queue_length}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zeitlinger I hope it's ok, I'm going to accept this change and merge, so we can get the (more important) parts into the upcoming release, since we don't have resolution yet on open-telemetry/semantic-conventions#95

Suggested change
.setUnit("{run_queue_length}")
.setUnit("1")

.buildWithCallback(
observableMeasurement -> {
double loadAverage = osBean.getSystemLoadAverage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ List<AutoCloseable> registerObservers(OpenTelemetry openTelemetry, ThreadMXBean
meter
.upDownCounterBuilder("process.runtime.jvm.threads.count")
.setDescription("Number of executing threads")
.setUnit("1")
.setUnit("{thread}")
.buildWithCallback(
observableMeasurement -> {
observableMeasurement.record(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void registerObservers() {
assertThat(metricData)
.hasInstrumentationScope(EXPECTED_SCOPE)
.hasDescription("Number of classes loaded since JVM start")
.hasUnit("1")
.hasUnit("{class}")
.hasLongSumSatisfying(
sum ->
sum.isMonotonic()
Expand All @@ -60,7 +60,7 @@ void registerObservers() {
assertThat(metricData)
.hasInstrumentationScope(EXPECTED_SCOPE)
.hasDescription("Number of classes unloaded since JVM start")
.hasUnit("1")
.hasUnit("{class}")
.hasLongSumSatisfying(
sum ->
sum.isMonotonic()
Expand All @@ -76,7 +76,7 @@ void registerObservers() {
assertThat(metricData)
.hasInstrumentationScope(EXPECTED_SCOPE)
.hasDescription("Number of classes currently loaded")
.hasUnit("1")
.hasUnit("{class}")
.hasLongSumSatisfying(
sum ->
sum.isNotMonotonic()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void registerObservers() {
assertThat(metricData)
.hasInstrumentationScope(EXPECTED_SCOPE)
.hasDescription("Average CPU load of the whole system for the last minute")
.hasUnit("1")
.hasUnit("{run_queue_length}")
trask marked this conversation as resolved.
Show resolved Hide resolved
.hasDoubleGaugeSatisfying(
gauge -> gauge.hasPointsSatisfying(point -> point.hasValue(2.2)))));
testing.waitAndAssertMetrics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void registerObservers() {
assertThat(metricData)
.hasInstrumentationScope(EXPECTED_SCOPE)
.hasDescription("Number of executing threads")
.hasUnit("1")
.hasUnit("{thread}")
.hasLongSumSatisfying(
sum ->
sum.isNotMonotonic()
Expand Down