Skip to content

Commit

Permalink
deprecation of db.connection_string
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainJuge committed Apr 9, 2024
1 parent 3cda45d commit 969c239
Show file tree
Hide file tree
Showing 25 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ abstract class DbClientCommonAttributesExtractor<
this.getter = getter;
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Override
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
internalSet(attributes, DbIncubatingAttributes.DB_SYSTEM, getter.getSystem(request));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public String getOperation(Map<String, String> map) {
}
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void shouldExtractAllAvailableAttributes() {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public String getConnectionString(Map<String, String> map) {
}
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void shouldExtractAllAttributes() {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static void cleanUp() {
}
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
static SpanDataAssert assertClientSpan(SpanDataAssert span, SpanData parent) {
return span.hasKind(SpanKind.CLIENT)
.hasParent(parent)
Expand All @@ -70,6 +71,7 @@ static SpanDataAssert assertClientSpan(SpanDataAssert span, SpanData parent) {
equalTo(DbIncubatingAttributes.DB_SQL_TABLE, "Value"));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
static SpanDataAssert assertClientSpan(SpanDataAssert span, SpanData parent, String verb) {
return span.hasName(verb.concat(" db1.Value"))
.hasKind(SpanKind.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class EntityManagerTest extends AbstractHibernateTest {
static final EntityManagerFactory entityManagerFactory =
Persistence.createEntityManagerFactory("test-pu");

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest
@MethodSource("provideArgumentsHibernateActionParameters")
void testHibernateActions(Parameter parameter) {
Expand Down Expand Up @@ -183,6 +184,7 @@ private static Stream<Arguments> provideArgumentsHibernateActionParameters() {
Arguments.of(named("remove", new Parameter("delete", true, true, EntityManager::remove))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testHibernatePersist() {
EntityManager entityManager = entityManagerFactory.createEntityManager();
Expand Down Expand Up @@ -254,6 +256,7 @@ void testHibernatePersist() {
equalTo(DbIncubatingAttributes.DB_SQL_TABLE, "Value"))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest
@MethodSource("provideArgumentsAttachesState")
void testAttachesStateToQuery(Function<EntityManager, Query> queryBuildMethod) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

class QueryTest extends AbstractHibernateTest {

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testHibernateQueryExecuteUpdateWithTransaction() {
testing.runWithSpan(
Expand Down Expand Up @@ -84,6 +85,7 @@ void testHibernateQueryExecuteUpdateWithTransaction() {
.get(stringKey("hibernate.session_id"))))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest
@MethodSource("providesArgumentsSingleCall")
void testHibernateQuerySingleCall(Parameter parameter) {
Expand Down Expand Up @@ -153,6 +155,7 @@ private static Stream<Arguments> providesArgumentsSingleCall() {
new Parameter("SELECT Value", sess -> sess.createQuery("from Value").scroll()))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testHibernateQueryIterate() {
testing.runWithSpan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
@SuppressWarnings("deprecation") // 'lock' is a deprecated method in the Session class
class SessionTest extends AbstractHibernateTest {

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest
@MethodSource("provideArgumentsHibernateAction")
void testHibernateAction(Parameter parameter) {
Expand Down Expand Up @@ -143,6 +144,7 @@ private static Stream<Arguments> provideArgumentsHibernateAction() {
null))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest
@MethodSource("provideArgumentsHibernateActionStateless")
void testHibernateActionStateless(Parameter parameter) {
Expand Down Expand Up @@ -290,6 +292,7 @@ private static Stream<Arguments> provideArgumentsHibernateActionStateless() {
}))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest
@MethodSource("provideArgumentsHibernateReplicate")
void testHibernateReplicate(Parameter parameter) {
Expand Down Expand Up @@ -437,6 +440,7 @@ void testHibernateFailedReplicate() {
.get(stringKey("hibernate.session_id"))))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest
@MethodSource("provideArgumentsHibernateCommitAction")
void testHibernateCommitAction(Parameter parameter) {
Expand Down Expand Up @@ -626,6 +630,7 @@ private static Stream<Arguments> provideArgumentsHibernateCommitAction() {
null))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest
@MethodSource("provideArgumentsStateQuery")
void testAttachesStateToQueryCreated(Consumer<Session> queryBuilder) {
Expand Down Expand Up @@ -698,6 +703,7 @@ private static Stream<Arguments> provideArgumentsStateQuery() {
session -> session.createSQLQuery("SELECT * FROM Value").list())))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testHibernateOverlappingSessions() {
testing.runWithSpan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class SpringJpaTest {
new AnnotationConfigApplicationContext(PersistenceConfig.class);
CustomerRepository repo = context.getBean(CustomerRepository.class);

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testCrud() {
String version = Version.getVersionString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private static Stream<Arguments> provideParameters() {
Arguments.of(named("getSingleResultOrNull", interactions.get(2))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("provideParameters")
void testCriteriaQuery(Consumer<Query<Value>> interaction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void testHibernateAction(Parameter parameter) {
});
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("provideAttachesStateParameters")
void testAttachesStateToQuery(Parameter parameter) {
Expand Down Expand Up @@ -287,6 +288,7 @@ private static class Parameter {
public final Function<EntityManager, Query> queryBuildMethod;
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
private static SpanDataAssert assertClientSpan(SpanDataAssert span, SpanData parent) {
return span.hasKind(SpanKind.CLIENT)
.hasParent(parent)
Expand All @@ -300,6 +302,7 @@ private static SpanDataAssert assertClientSpan(SpanDataAssert span, SpanData par
equalTo(DbIncubatingAttributes.DB_SQL_TABLE, "Value"));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
private static SpanDataAssert assertClientSpan(
SpanDataAssert span, SpanData parent, String spanName) {
return span.hasName(spanName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static void cleanup() {
}
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testProcedureCall() {
testing.runWithSpan(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ void testHibernateCommitAction(Parameter parameter) {
span -> assertClientSpan(span, trace.getSpan(2))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("provideAttachesStateToQueryParameters")
void testAttachesStateToQuery(Parameter parameter) {
Expand Down Expand Up @@ -802,6 +803,7 @@ private static SpanDataAssert assertSpanWithSessionId(
equalTo(AttributeKey.stringKey("hibernate.session_id"), sessionId));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
private static SpanDataAssert assertClientSpan(SpanDataAssert span, SpanData parent) {
return span.hasKind(SpanKind.CLIENT)
.hasParent(parent)
Expand All @@ -815,6 +817,7 @@ private static SpanDataAssert assertClientSpan(SpanDataAssert span, SpanData par
equalTo(DbIncubatingAttributes.DB_SQL_TABLE, "Value"));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
private static SpanDataAssert assertClientSpan(
SpanDataAssert span, SpanData parent, String verb) {
return span.hasName(verb.concat(" db1.Value"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
@Shared
def repo = context.getBean(CustomerRepository)

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
def "test CRUD"() {
setup:
def isHibernate4 = Version.getVersionString().startsWith("4.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ static void cleanUp() {
}
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testProcedureCall() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class JdbcInstrumentationTest extends AgentInstrumentationSpecification {
}
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
def "basic statement with #connection.getClass().getCanonicalName() on #system generates spans"() {
setup:
Statement statement = connection.createStatement()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class SlickTest {
Duration.Inf
)

@SuppressWarnings(
"deprecation"
) // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
def basicStatement(): Unit = {
val result = getResults(startQuery(TestQuery))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum DataSourceDbAttributesExtractor implements AttributesExtractor<DataSource,
@Override
public void onStart(AttributesBuilder attributes, Context parentContext, DataSource dataSource) {}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Override
public void onEnd(
AttributesBuilder attributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import static io.opentelemetry.instrumentation.jdbc.internal.JdbcInstrumenterFac

class OpenTelemetryConnectionTest extends InstrumentationSpecification implements LibraryTestTrait {

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
def "verify create statement"() {
setup:
def instr = createStatementInstrumenter(openTelemetry)
Expand Down Expand Up @@ -80,6 +81,7 @@ class OpenTelemetryConnectionTest extends InstrumentationSpecification implement
connection.createStatement().instrumenter == instr
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
def "verify prepare statement"() {
setup:
def instr = createStatementInstrumenter(openTelemetry)
Expand Down Expand Up @@ -140,6 +142,7 @@ class OpenTelemetryConnectionTest extends InstrumentationSpecification implement
connection.prepareStatement(query).instrumenter == instr
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
def "verify prepare call"() {
setup:
def instr = createStatementInstrumenter(openTelemetry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class OpenTelemetryDataSourceTest {
@RegisterExtension
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest
@ArgumentsSource(GetConnectionMethods.class)
void shouldEmitGetConnectionSpans(GetConnectionFunction getConnection) throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ abstract class AbstractMongoClientTest<T> extends InstrumentationSpecification {
return "testCollection-${collectionIndex.getAndIncrement()}"
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
def mongoSpan(TraceAssert trace, int index,
String operation, String collection,
String dbName, Object parentSpan,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ void startContainer(DbSystemProps props) {
}
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("provideParameters")
void testQueries(Parameter parameter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static void cleanUp() {
applicationContext.close();
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testFindAll() {
long count =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void testObjectMethod() {
span -> span.hasName("toString test").hasTotalAttributeCount(0)));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
static void assertHibernate4Trace(TraceAssert trace, String repoClassName) {
trace.hasSpansSatisfyingExactly(
span ->
Expand All @@ -89,6 +90,7 @@ static void assertHibernate4Trace(TraceAssert trace, String repoClassName) {
equalTo(DbIncubatingAttributes.DB_SQL_TABLE, "JpaCustomer")));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
static void assertHibernateTrace(TraceAssert trace, String repoClassName) {
trace.hasSpansSatisfyingExactly(
span ->
Expand Down Expand Up @@ -124,6 +126,7 @@ static void assertHibernateTrace(TraceAssert trace, String repoClassName) {
equalTo(DbIncubatingAttributes.DB_SQL_TABLE, "JpaCustomer")));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testCrud() {
boolean isHibernate4 = Version.getVersionString().startsWith("4.");
Expand Down Expand Up @@ -278,6 +281,7 @@ void testCrud() {
equalTo(DbIncubatingAttributes.DB_SQL_TABLE, "JpaCustomer"))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testCustomRepositoryMethod() {
REPOSITORY repo = repository();
Expand Down Expand Up @@ -312,6 +316,7 @@ void testCustomRepositoryMethod() {
equalTo(DbIncubatingAttributes.DB_SQL_TABLE, "JpaCustomer"))));
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void testFailedRepositoryMethod() {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {

//Verifies that context is correctly propagated and sql query span has correct parent.
//Tests io.opentelemetry.javaagent.instrumentation.vertx.reactive.VertxRxInstrumentation
@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
def "should propagate context over vert.x rx-java framework"() {
setup:
def response = client.get("/listProducts").aggregate().join()
Expand Down Expand Up @@ -110,6 +111,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
}
}

@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
def "should propagate context correctly over vert.x rx-java framework with high concurrency"() {
setup:
int count = 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {

//Verifies that context is correctly propagated and sql query span has correct parent.
//Tests io.opentelemetry.javaagent.instrumentation.vertx.reactive.VertxRxInstrumentation
@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
def "should propagate context over vert.x rx-java framework"() {
setup:
def response = client.get("/listProducts").aggregate().join()
Expand Down

0 comments on commit 969c239

Please sign in to comment.