Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement stable database semantic conventions #11575

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
9728c0d
Protype for db stable semconv
heyams Jun 13, 2024
46ee9f7
Update redis db.namespace value
heyams Jun 13, 2024
817dc2d
Update
heyams Jun 13, 2024
8b26641
Update
heyams Jul 31, 2024
a0464be
Merge remote-tracking branch 'upstream/main' into heya/implement-data…
heyams Jul 31, 2024
cb4e57c
Use inline
heyams Aug 9, 2024
338549a
Merge remote-tracking branch 'upstream/main' into heya/implement-data…
heyams Aug 9, 2024
7d718cb
Fix
heyams Aug 9, 2024
818c9c8
Fix compilation error
heyams Aug 9, 2024
13f78f4
Fix
heyams Aug 9, 2024
aeac9d2
Merge remote-tracking branch 'upstream/main' into heya/implement-data…
heyams Aug 19, 2024
dd168ee
Update
heyams Aug 19, 2024
5106782
Fix
heyams Aug 20, 2024
27be3ed
Comment
heyams Aug 20, 2024
d4d332e
Suppress deprecation
heyams Aug 20, 2024
bd3a77d
Fix deprecation
heyams Aug 20, 2024
6714f40
Fix span name for vertxRedisClient
heyams Aug 21, 2024
fc6caa5
Fix couchbaseSpringRepositoryTest
heyams Aug 21, 2024
0cb4c9d
Fix
heyams Aug 21, 2024
9abe6e5
Merge remote-tracking branch 'upstream/main' into heya/implement-data…
heyams Aug 21, 2024
5458730
Merge remote-tracking branch 'upstream/main' into heya/implement-data…
heyams Aug 27, 2024
0b41bdd
Fix network_type
heyams Aug 28, 2024
fe8fe48
Fix cassandra tests
heyams Aug 28, 2024
7a4234d
Fix cassandraClient test
heyams Aug 28, 2024
76fa8be
Fix RedissonClientTest
heyams Aug 29, 2024
2007a22
Fix db.statement vs. db.query.text
heyams Aug 29, 2024
2ae1354
Fix
heyams Aug 29, 2024
ed94de3
Fix AbstractRedissonAsyncClientTest
heyams Aug 29, 2024
da00aa2
Fix
heyams Aug 29, 2024
f62fc39
Fix
heyams Aug 29, 2024
9dac540
Fix couchbase tests
heyams Aug 29, 2024
066897a
Fix
heyams Aug 29, 2024
181ee2c
Fix codenarc
heyams Aug 29, 2024
be44287
Fix cassandraclienttest 3.0
heyams Aug 29, 2024
c5b8888
Fix cassandra sync test
heyams Aug 30, 2024
dd5b1ef
Fix
heyams Aug 30, 2024
e80ead2
Fix
heyams Aug 30, 2024
0536e20
Fix
heyams Aug 30, 2024
a999f1b
Deprecate getUser and getConnectionString
heyams Sep 9, 2024
a956705
Deprecate getOperation and getStatement
heyams Sep 9, 2024
9cdd39f
Revert
heyams Sep 9, 2024
566318a
Remove supressionWarning
heyams Sep 9, 2024
616b243
Fix
heyams Sep 9, 2024
6e09209
Fix
heyams Sep 10, 2024
63261be
Fix deprecation
heyams Sep 10, 2024
78278e8
Fix
heyams Sep 10, 2024
63fad77
Fix
heyams Sep 10, 2024
a4bbdfc
Fix
heyams Sep 10, 2024
3b60339
Merge remote-tracking branch 'upstream/main' into heya/implement-data…
heyams Sep 13, 2024
14495e3
Fix couchbase tests
heyams Sep 13, 2024
7928bb4
Fix
heyams Sep 13, 2024
60c344f
Fix
heyams Sep 16, 2024
39743eb
Fix
heyams Sep 16, 2024
4171532
Rename getOperationName to getDbOperationName
heyams Sep 17, 2024
dbc596f
Rename getNamespace to getDbNamespace
heyams Sep 17, 2024
f449cf8
Deprecate getSystem and introduce getDbSystem
heyams Sep 17, 2024
8f841e1
Delete SemconvStability.getAttributeKey
heyams Sep 17, 2024
4820887
Fix unused var
heyams Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use inline
  • Loading branch information
heyams committed Aug 9, 2024
commit cb4e57c5cf00e20612d81617d781ae7fa9c57537
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ tasks {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

check {
dependsOn(testStableSemconv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public final class CassandraSingletons {
// could use RESPONSE "ResultSet" here, but using RESPONSE "ExecutionInfo" in cassandra-4.0
// instrumentation (see comment over there for why), so also using here for consistency
private static final Instrumenter<CassandraRequest, ExecutionInfo> INSTRUMENTER;
private static final AttributeKey<String> DB_COLLECTION_NAME = AttributeKey.stringKey("db.collection.name");
private static final AttributeKey<String> DB_COLLECTION_NAME =
AttributeKey.stringKey("db.collection.name");

static {
CassandraSqlAttributesGetter attributesGetter = new CassandraSqlAttributesGetter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ResultSetFuture;
import com.datastax.driver.core.Session;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
Expand Down Expand Up @@ -102,7 +101,9 @@ void syncTest(Parameter parameter) {
equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort),
equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"),
equalTo(
getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), "USE " + parameter.keyspace))),
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_STATEMENT),
"USE " + parameter.keyspace))),
trace ->
trace.hasSpansSatisfyingExactly(
span ->
Expand All @@ -116,11 +117,22 @@ void syncTest(Parameter parameter) {
equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp),
equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort),
equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"),
equalTo(getAttributeKey(DbIncubatingAttributes.DB_NAME), parameter.keyspace),
equalTo(
getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement),
equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation),
equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table))));
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_NAME),
parameter.keyspace),
equalTo(
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_STATEMENT),
parameter.expectedStatement),
equalTo(
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_OPERATION),
parameter.operation),
equalTo(
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_CASSANDRA_TABLE),
parameter.table))));
} else {
testing.waitAndAssertTraces(
trace ->
Expand All @@ -136,9 +148,17 @@ void syncTest(Parameter parameter) {
equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort),
equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"),
equalTo(
getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement),
equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation),
equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table))));
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_STATEMENT),
parameter.expectedStatement),
equalTo(
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_OPERATION),
parameter.operation),
equalTo(
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_CASSANDRA_TABLE),
parameter.table))));
}

session.close();
Expand Down Expand Up @@ -176,7 +196,8 @@ void asyncTest(Parameter parameter) {
equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort),
equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"),
equalTo(
getAttributeKey(DbIncubatingAttributes.DB_STATEMENT),
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_STATEMENT),
"USE " + parameter.keyspace))),
trace ->
trace.hasSpansSatisfyingExactly(
Expand All @@ -191,11 +212,22 @@ void asyncTest(Parameter parameter) {
equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp),
equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort),
equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"),
equalTo(getAttributeKey(DbIncubatingAttributes.DB_NAME), parameter.keyspace),
equalTo(
getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement),
equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation),
equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table)),
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_NAME),
parameter.keyspace),
equalTo(
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_STATEMENT),
parameter.expectedStatement),
equalTo(
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_OPERATION),
parameter.operation),
equalTo(
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_CASSANDRA_TABLE),
parameter.table)),
span ->
span.hasName("callbackListener")
.hasKind(SpanKind.INTERNAL)
Expand All @@ -216,9 +248,17 @@ void asyncTest(Parameter parameter) {
equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort),
equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"),
equalTo(
getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement),
equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation),
equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table)),
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_STATEMENT),
parameter.expectedStatement),
equalTo(
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_OPERATION),
parameter.operation),
equalTo(
SemconvStabilityUtil.getAttributeKey(
DbIncubatingAttributes.DB_CASSANDRA_TABLE),
parameter.table)),
span ->
span.hasName("callbackListener")
.hasKind(SpanKind.INTERNAL)
Expand All @@ -228,10 +268,6 @@ void asyncTest(Parameter parameter) {
session.close();
}

protected static <T> AttributeKey<T> getAttributeKey(AttributeKey<T> oldKey) {
return SemconvStabilityUtil.getAttributeKey(oldKey);
}

private static Stream<Arguments> provideSyncParameters() {
return Stream.of(
Arguments.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ tasks {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}

check {
dependsOn(testStableSemconv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ tasks {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

withType<Test>().configureEach {
// TODO run tests both with and without experimental span attributes
jvmArgs("-Dotel.instrumentation.couchbase.experimental-span-attributes=true")

// required on jdk17
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
withType<Test>().configureEach {
// TODO run tests both with and without experimental span attributes
jvmArgs("-Dotel.instrumentation.couchbase.experimental-span-attributes=true")

// required on jdk17
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}

check {
dependsOn(testStableSemconv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ tasks {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

withType<Test>().configureEach {
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
withType<Test>().configureEach {
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

check {
dependsOn(testStableSemconv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import java.util.List;

/**
* <p>In case you enable the preview of stable database semantic conventions (e.g. by setting the {@code
* otel.semconv-stability.opt-in} system property to {@code database}), the metrics being exported will
* follow <a
* href="https://github.com/open-telemetry/semantic-conventions/tree/main/docs/database">the
* most recent database semantic conventions</a>.
* In case you enable the preview of stable database semantic conventions (e.g. by setting the
* {@code otel.semconv-stability.opt-in} system property to {@code database}), the metrics being
* exported will follow <a
* href="https://github.com/open-telemetry/semantic-conventions/tree/main/docs/database">the most
* recent database semantic conventions</a>.
*
* Registers measurements that generate metrics about JVM classes. The metrics generated by this
* <p>Registers measurements that generate metrics about JVM classes. The metrics generated by this
* class follow <a
* href="https://github.com/open-telemetry/semantic-conventions/blob/main/docs/runtime/jvm-metrics.md">the
* stable JVM metrics semantic conventions</a>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

package io.opentelemetry.instrumentation.testing.junit.db;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import java.util.HashMap;
import java.util.Map;

import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_CASSANDRA_TABLE;
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_COSMOSDB_CONTAINER;
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_MONGODB_COLLECTION;
Expand All @@ -19,14 +14,21 @@
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SQL_TABLE;
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_STATEMENT;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import java.util.HashMap;
import java.util.Map;

// until old database semconv are dropped in 3.0
public class SemconvStabilityUtil {
private static final Map<AttributeKey<?>, AttributeKey<?>> oldToNewMap = new HashMap<>();
private static final AttributeKey<String> DB_NAMESPACE = AttributeKey.stringKey("db.namespace");
private static final AttributeKey<Long> DB_NAMESPACE_LONG = AttributeKey.longKey("db.namespace");
private static final AttributeKey<String> DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text");
private static final AttributeKey<String> DB_OPERATION_NAME = AttributeKey.stringKey("db.operation.name");
private static final AttributeKey<String> DB_COLLECTION_NAME = AttributeKey.stringKey("db.collection.name");
private static final AttributeKey<String> DB_OPERATION_NAME =
AttributeKey.stringKey("db.operation.name");
private static final AttributeKey<String> DB_COLLECTION_NAME =
AttributeKey.stringKey("db.collection.name");

static {
addKey(oldToNewMap, DB_NAME, DB_NAMESPACE);
Expand Down