Skip to content

Commit

Permalink
rebase after SDK update
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Rzeszutek committed May 11, 2022
1 parent 9b16af7 commit 63b151c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 82 deletions.
1 change: 1 addition & 0 deletions docs/supported-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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+ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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))))));
}
}

0 comments on commit 63b151c

Please sign in to comment.