Skip to content

Commit

Permalink
Refactored client metrics (#139)
Browse files Browse the repository at this point in the history
* Refactored client metrics

* Fixed descriptions

* Fixed integration tests

* Fixed imports

* spotless

* Fixed metric name in integration test
  • Loading branch information
merlimat authored May 2, 2024
1 parent 10e5ca8 commit d03623c
Show file tree
Hide file tree
Showing 54 changed files with 1,257 additions and 1,717 deletions.
6 changes: 0 additions & 6 deletions client-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.streamnative.oxia</groupId>
<artifactId>oxia-client-metrics-opentelemetry</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.streamnative.oxia</groupId>
<artifactId>oxia-testcontainers</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import io.streamnative.oxia.client.api.Notification.KeyModified;
import io.streamnative.oxia.client.api.PutOption;
import io.streamnative.oxia.client.api.UnexpectedVersionIdException;
import io.streamnative.oxia.client.metrics.opentelemetry.OpenTelemetryMetrics;
import io.streamnative.oxia.testcontainers.OxiaContainer;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -84,11 +83,11 @@ static void beforeAll() {
SdkMeterProvider.builder().registerMetricReader(metricReader).setResource(resource).build();

OpenTelemetry openTelemetry =
OpenTelemetrySdk.builder().setMeterProvider(sdkMeterProvider).buildAndRegisterGlobal();
OpenTelemetrySdk.builder().setMeterProvider(sdkMeterProvider).build();

client =
new OxiaClientBuilder(oxia.getServiceAddress())
.metrics(OpenTelemetryMetrics.create(openTelemetry))
.openTelemetry(openTelemetry)
.asyncClient()
.join();
client.notifications(notifications::add);
Expand Down Expand Up @@ -204,15 +203,12 @@ void test() throws Exception {
var metrics = metricReader.collectAllMetrics();
var metricsByName = metrics.stream().collect(Collectors.toMap(MetricData::getName, identity()));

System.out.println(metricsByName);

assertThat(
metricsByName.get("oxia_client_operation_size").getHistogramData().getPoints().stream()
.map(HistogramPointData::getCount)
.reduce(0L, Long::sum))
.isEqualTo(18);
assertThat(
metricsByName.get("oxia_client_cache_hits").getHistogramData().getPoints().stream()
metricsByName.get("oxia.client.ops").getHistogramData().getPoints().stream()
.map(HistogramPointData::getCount)
.reduce(0L, Long::sum))
.isEqualTo(11);
.isEqualTo(24);
}
}
32 changes: 0 additions & 32 deletions client-metrics-api/pom.xml

This file was deleted.

This file was deleted.

44 changes: 0 additions & 44 deletions client-metrics-opentelemetry/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 4 additions & 5 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,15 @@
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>io.streamnative.oxia</groupId>
<artifactId>oxia-client-metrics-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
Expand Down
Loading

0 comments on commit d03623c

Please sign in to comment.