Skip to content

Commit

Permalink
incorporate pr comments
Browse files Browse the repository at this point in the history
Signed-off-by: Gagan Juneja <gjjuneja@amazon.com>
  • Loading branch information
Gagan Juneja committed Mar 14, 2024
1 parent 2a626bb commit 4c9768b
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public Histogram createHistogram(String name, String description, String unit) {
}

@Override
public Closeable createObservableGauge(String name, String description, String unit, Supplier<Double> valueProvider, Tags tags) {
return metricsTelemetry.createObservableGauge(name, description, unit, valueProvider, tags);
public Closeable createGauge(String name, String description, String unit, Supplier<Double> valueProvider, Tags tags) {
return metricsTelemetry.createGauge(name, description, unit, valueProvider, tags);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public interface MetricsRegistry extends Closeable {
* @param unit unit of the metric.
* @param valueProvider value provider.
* @param tags attributes/dimensions of the metric.
* @return observableGauge.
* @return closeable to dispose/close the Gauge metric.
*/
Closeable createObservableGauge(String name, String description, String unit, Supplier<Double> valueProvider, Tags tags);
Closeable createGauge(String name, String description, String unit, Supplier<Double> valueProvider, Tags tags);

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Histogram createHistogram(String name, String description, String unit) {
}

@Override
public Closeable createObservableGauge(String name, String description, String unit, Supplier<Double> valueProvider, Tags tags) {
public Closeable createGauge(String name, String description, String unit, Supplier<Double> valueProvider, Tags tags) {
return () -> {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,9 @@ public void testHistogram() {
public void testObservableGauge() {
Closeable mockCloseable = mock(Closeable.class);
when(
defaultMeterRegistry.createObservableGauge(
any(String.class),
any(String.class),
any(String.class),
any(Supplier.class),
any(Tags.class)
)
defaultMeterRegistry.createGauge(any(String.class), any(String.class), any(String.class), any(Supplier.class), any(Tags.class))
).thenReturn(mockCloseable);
Closeable closeable = defaultMeterRegistry.createObservableGauge(
Closeable closeable = defaultMeterRegistry.createGauge(
"org.opensearch.telemetry.metrics.DefaultMeterRegistryTests.testObservableGauge",
"test observable gauge",
"ms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void testObservableGauge() throws Exception {
Tags tags = Tags.create().addTag("test", "integ-test");
final AtomicInteger testValue = new AtomicInteger(0);
Supplier<Double> valueProvider = () -> { return Double.valueOf(testValue.incrementAndGet()); };
Closeable gaugeCloseable = metricsRegistry.createObservableGauge(metricName, "test", "ms", valueProvider, tags);
Closeable gaugeCloseable = metricsRegistry.createGauge(metricName, "test", "ms", valueProvider, tags);
// Sleep for about 2.2s to wait for metrics to be published.
Thread.sleep(2200);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Histogram createHistogram(String name, String description, String unit) {
}

@Override
public Closeable createObservableGauge(String name, String description, String unit, Supplier<Double> valueProvider, Tags tags) {
public Closeable createGauge(String name, String description, String unit, Supplier<Double> valueProvider, Tags tags) {
ObservableDoubleGauge doubleObservableGauge = AccessController.doPrivileged(
(PrivilegedAction<ObservableDoubleGauge>) () -> otelMeter.gaugeBuilder(name)
.setUnit(unit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void testObservableGauge() throws Exception {
when(mockOTelDoubleGaugeBuilder.setUnit(unit)).thenReturn(mockOTelDoubleGaugeBuilder);
when(mockOTelDoubleGaugeBuilder.buildWithCallback(any(Consumer.class))).thenReturn(observableDoubleGauge);

Closeable closeable = metricsTelemetry.createObservableGauge(observableGaugeName, description, unit, () -> 1.0, Tags.EMPTY);
Closeable closeable = metricsTelemetry.createGauge(observableGaugeName, description, unit, () -> 1.0, Tags.EMPTY);
closeable.close();
verify(observableDoubleGauge).close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ public Histogram createHistogram(String name, String description, String unit) {
}

@Override
public Closeable createObservableGauge(
String name,
String description,
String unit,
Supplier<Double> valueProvider,
Tags tags
) {
public Closeable createGauge(String name, String description, String unit, Supplier<Double> valueProvider, Tags tags) {
return () -> {};
}

Expand Down

0 comments on commit 4c9768b

Please sign in to comment.