-
Notifications
You must be signed in to change notification settings - Fork 875
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add db client metrics for JDBC, vertx, r2dbc, cassandra, add tests (#…
- Loading branch information
1 parent
965e886
commit 3fd27aa
Showing
11 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../main/java/io/opentelemetry/instrumentation/testing/junit/db/DbClientMetricsTestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.testing.junit.db; | ||
|
||
import static io.opentelemetry.instrumentation.api.internal.SemconvStability.emitStableDatabaseSemconv; | ||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; | ||
|
||
import io.opentelemetry.api.common.AttributeKey; | ||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
|
||
public class DbClientMetricsTestUtil { | ||
|
||
private DbClientMetricsTestUtil() {} | ||
|
||
public static void assertDurationMetric( | ||
InstrumentationExtension testing, | ||
String instrumentationName, | ||
AttributeKey<?>... expectedKeys) { | ||
if (!emitStableDatabaseSemconv()) { | ||
return; | ||
} | ||
testing.waitAndAssertMetrics( | ||
instrumentationName, | ||
metrics -> | ||
metrics | ||
.hasName("db.client.operation.duration") | ||
.hasUnit("s") | ||
.hasDescription("Duration of database client operations.") | ||
.hasHistogramSatisfying( | ||
histogram -> | ||
histogram.hasPointsSatisfying( | ||
point -> | ||
point.hasAttributesSatisfying( | ||
attributes -> | ||
assertThat(attributes.asMap()) | ||
.containsOnlyKeys(expectedKeys))))); | ||
} | ||
} |