From a9a31a09461a026d585a5a9d5fe5a13a5f3a111e Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Fri, 7 Feb 2020 13:17:31 -0800 Subject: [PATCH] Fix direct record methods on instrument to call unbind. (#836) Signed-off-by: Bogdan Cristian Drutu --- .../java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java | 4 +++- .../java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java | 4 +++- .../java/io/opentelemetry/sdk/metrics/LongCounterSdk.java | 4 +++- .../java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java index 2c4e5aac19a..086e7726d18 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleCounterSdk.java @@ -38,7 +38,9 @@ private DoubleCounterSdk( @Override public void add(double delta, LabelSet labelSet) { - bind(labelSet).add(delta); + BoundDoubleCounter boundDoubleCounter = bind(labelSet); + boundDoubleCounter.add(delta); + boundDoubleCounter.unbind(); } @Override diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java index e3241385384..9cbb024919f 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleMeasureSdk.java @@ -38,7 +38,9 @@ private DoubleMeasureSdk( @Override public void record(double value, LabelSet labelSet) { - bind(labelSet).record(value); + BoundDoubleMeasure boundDoubleMeasure = bind(labelSet); + boundDoubleMeasure.record(value); + boundDoubleMeasure.unbind(); } @Override diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java index d9197f9e078..0af5ef61e4d 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongCounterSdk.java @@ -38,7 +38,9 @@ private LongCounterSdk( @Override public void add(long delta, LabelSet labelSet) { - bind(labelSet).add(delta); + BoundLongCounter boundLongCounter = bind(labelSet); + boundLongCounter.add(delta); + boundLongCounter.unbind(); } @Override diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java index 1f26a5bf287..14d921e247f 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/LongMeasureSdk.java @@ -38,7 +38,9 @@ private LongMeasureSdk( @Override public void record(long value, LabelSet labelSet) { - bind(labelSet).record(value); + BoundLongMeasure boundLongMeasure = bind(labelSet); + boundLongMeasure.record(value); + boundLongMeasure.unbind(); } @Override