diff --git a/docs/supported-libraries.md b/docs/supported-libraries.md index 38c9a025a772..189c60b583ed 100644 --- a/docs/supported-libraries.md +++ b/docs/supported-libraries.md @@ -61,6 +61,7 @@ These are the supported libraries and frameworks: | [Guava ListenableFuture](https://guava.dev/releases/snapshot/api/docs/com/google/common/util/concurrent/ListenableFuture.html) | 10.0+ | | [GWT](http://www.gwtproject.org/) | 2.0+ | | [Hibernate](https://github.com/hibernate/hibernate-orm) | 3.3+ | +| [HikariCP](https://github.com/brettwooldridge/HikariCP) | 3.0+ | | [HttpURLConnection](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/HttpURLConnection.html) | Java 8+ | | [Hystrix](https://github.com/Netflix/Hystrix) | 1.4+ | | [Java Executors](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executor.html) | Java 8+ | diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/DbConnectionPoolMetricsAssertions.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/DbConnectionPoolMetricsAssertions.java index 62afe6c4fc6a..30ae076b462e 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/DbConnectionPoolMetricsAssertions.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/DbConnectionPoolMetricsAssertions.java @@ -6,7 +6,7 @@ package io.opentelemetry.instrumentation.testing.junit.db; import static io.opentelemetry.api.common.AttributeKey.stringKey; -import static io.opentelemetry.sdk.testing.assertj.MetricAssertions.assertThat; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; @@ -53,26 +53,24 @@ public void assertConnectionPoolEmitsMetrics() { .hasUnit("connections") .hasDescription( "The number of connections that are currently in state described by the state attribute.") - .hasLongSum() - .isNotMonotonic() - .points() - .satisfiesExactlyInAnyOrder( - point -> - assertThat(point) - .hasAttributes( - Attributes.of( - stringKey("pool.name"), - poolName, - stringKey("state"), - "idle")), - point -> - assertThat(point) - .hasAttributes( - Attributes.of( - stringKey("pool.name"), - poolName, - stringKey("state"), - "used"))))); + .hasLongSumSatisfying( + sum -> + sum.isNotMonotonic() + .hasPointsSatisfying( + point -> + point.hasAttributes( + Attributes.of( + stringKey("pool.name"), + poolName, + stringKey("state"), + "idle")), + point -> + point.hasAttributes( + Attributes.of( + stringKey("pool.name"), + poolName, + stringKey("state"), + "used")))))); testing.waitAndAssertMetrics( instrumentationName, "db.client.connections.idle.min", @@ -82,14 +80,14 @@ public void assertConnectionPoolEmitsMetrics() { assertThat(metric) .hasUnit("connections") .hasDescription("The minimum number of idle open connections allowed.") - .hasLongSum() - .isNotMonotonic() - .points() - .satisfiesExactly( - point -> - assertThat(point) - .hasAttributes( - Attributes.of(stringKey("pool.name"), poolName))))); + .hasLongSumSatisfying( + sum -> + sum.isNotMonotonic() + .hasPointsSatisfying( + point -> + point.hasAttributes( + Attributes.of( + stringKey("pool.name"), poolName)))))); if (testMaxIdleConnections) { testing.waitAndAssertMetrics( instrumentationName, @@ -100,14 +98,14 @@ public void assertConnectionPoolEmitsMetrics() { assertThat(metric) .hasUnit("connections") .hasDescription("The maximum number of idle open connections allowed.") - .hasLongSum() - .isNotMonotonic() - .points() - .satisfiesExactly( - point -> - assertThat(point) - .hasAttributes( - Attributes.of(stringKey("pool.name"), poolName))))); + .hasLongSumSatisfying( + sum -> + sum.isNotMonotonic() + .hasPointsSatisfying( + point -> + point.hasAttributes( + Attributes.of( + stringKey("pool.name"), poolName)))))); } testing.waitAndAssertMetrics( instrumentationName, @@ -118,14 +116,14 @@ public void assertConnectionPoolEmitsMetrics() { assertThat(metric) .hasUnit("connections") .hasDescription("The maximum number of open connections allowed.") - .hasLongSum() - .isNotMonotonic() - .points() - .satisfiesExactly( - point -> - assertThat(point) - .hasAttributes( - Attributes.of(stringKey("pool.name"), poolName))))); + .hasLongSumSatisfying( + sum -> + sum.isNotMonotonic() + .hasPointsSatisfying( + point -> + point.hasAttributes( + Attributes.of( + stringKey("pool.name"), poolName)))))); testing.waitAndAssertMetrics( instrumentationName, "db.client.connections.pending_requests", @@ -136,14 +134,14 @@ public void assertConnectionPoolEmitsMetrics() { .hasUnit("requests") .hasDescription( "The number of pending requests for an open connection, cumulative for the entire pool.") - .hasLongSum() - .isNotMonotonic() - .points() - .satisfiesExactly( - point -> - assertThat(point) - .hasAttributes( - Attributes.of(stringKey("pool.name"), poolName))))); + .hasLongSumSatisfying( + sum -> + sum.isNotMonotonic() + .hasPointsSatisfying( + point -> + point.hasAttributes( + Attributes.of( + stringKey("pool.name"), poolName)))))); if (testConnectionTimeouts) { testing.waitAndAssertMetrics( instrumentationName, @@ -155,14 +153,14 @@ public void assertConnectionPoolEmitsMetrics() { .hasUnit("timeouts") .hasDescription( "The number of connection timeouts that have occurred trying to obtain a connection from the pool.") - .hasLongSum() - .isMonotonic() - .points() - .satisfiesExactly( - point -> - assertThat(point) - .hasAttributes( - Attributes.of(stringKey("pool.name"), poolName))))); + .hasLongSumSatisfying( + sum -> + sum.isMonotonic() + .hasPointsSatisfying( + point -> + point.hasAttributes( + Attributes.of( + stringKey("pool.name"), poolName)))))); } testing.waitAndAssertMetrics( instrumentationName, @@ -173,13 +171,12 @@ public void assertConnectionPoolEmitsMetrics() { assertThat(metric) .hasUnit("ms") .hasDescription("The time it took to create a new connection.") - .hasDoubleHistogram() - .points() - .satisfiesExactly( - point -> - assertThat(point) - .hasAttributes( - Attributes.of(stringKey("pool.name"), poolName))))); + .hasHistogramSatisfying( + histogram -> + histogram.hasPointsSatisfying( + point -> + point.hasAttributes( + Attributes.of(stringKey("pool.name"), poolName)))))); testing.waitAndAssertMetrics( instrumentationName, "db.client.connections.wait_time", @@ -190,13 +187,12 @@ public void assertConnectionPoolEmitsMetrics() { .hasUnit("ms") .hasDescription( "The time it took to obtain an open connection from the pool.") - .hasDoubleHistogram() - .points() - .satisfiesExactly( - point -> - assertThat(point) - .hasAttributes( - Attributes.of(stringKey("pool.name"), poolName))))); + .hasHistogramSatisfying( + histogram -> + histogram.hasPointsSatisfying( + point -> + point.hasAttributes( + Attributes.of(stringKey("pool.name"), poolName)))))); testing.waitAndAssertMetrics( instrumentationName, "db.client.connections.use_time", @@ -207,12 +203,11 @@ public void assertConnectionPoolEmitsMetrics() { .hasUnit("ms") .hasDescription( "The time between borrowing a connection and returning it to the pool.") - .hasDoubleHistogram() - .points() - .satisfiesExactly( - point -> - assertThat(point) - .hasAttributes( - Attributes.of(stringKey("pool.name"), poolName))))); + .hasHistogramSatisfying( + histogram -> + histogram.hasPointsSatisfying( + point -> + point.hasAttributes( + Attributes.of(stringKey("pool.name"), poolName)))))); } }