|
@@ -61,72 +61,64 @@ public abstract class AbstractSpringJpaTest<
|
|
|
// Asserting that a span is NOT created for toString
|
|
|
testing.waitAndAssertTraces(
|
|
|
trace ->
|
|
|
- trace
|
|
|
- .hasSize(1)
|
|
|
- .hasSpansSatisfyingExactly(
|
|
|
- span -> span.hasName("toString test").hasTotalAttributeCount(0)));
|
|
|
+ trace.hasSpansSatisfyingExactly(
|
|
|
+ span -> span.hasName("toString test").hasTotalAttributeCount(0)));
|
|
|
}
|
|
|
|
|
|
static void assertHibernate4Trace(TraceAssert trace, String repoClassName) {
|
|
|
- trace
|
|
|
- .hasSize(2)
|
|
|
- .hasSpansSatisfyingExactly(
|
|
|
- span ->
|
|
|
- span.hasName("JpaCustomerRepository.save")
|
|
|
- .hasKind(SpanKind.INTERNAL)
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
- equalTo(SemanticAttributes.CODE_FUNCTION, "save")),
|
|
|
- span ->
|
|
|
- span.hasName("INSERT test.JpaCustomer")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasParent(trace.getSpan(0))
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT, val -> val.startsWith("insert ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "INSERT"),
|
|
|
- equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer")));
|
|
|
+ trace.hasSpansSatisfyingExactly(
|
|
|
+ span ->
|
|
|
+ span.hasName("JpaCustomerRepository.save")
|
|
|
+ .hasKind(SpanKind.INTERNAL)
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
+ equalTo(SemanticAttributes.CODE_FUNCTION, "save")),
|
|
|
+ span ->
|
|
|
+ span.hasName("INSERT test.JpaCustomer")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasParent(trace.getSpan(0))
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(SemanticAttributes.DB_STATEMENT, val -> val.startsWith("insert ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "INSERT"),
|
|
|
+ equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer")));
|
|
|
}
|
|
|
|
|
|
static void assertHibernateTrace(TraceAssert trace, String repoClassName) {
|
|
|
- trace
|
|
|
- .hasSize(3)
|
|
|
- .hasSpansSatisfyingExactly(
|
|
|
- span ->
|
|
|
- span.hasName("JpaCustomerRepository.save")
|
|
|
- .hasKind(SpanKind.INTERNAL)
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
- equalTo(SemanticAttributes.CODE_FUNCTION, "save")),
|
|
|
- span ->
|
|
|
- span.hasName("CALL test")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT,
|
|
|
- val -> val.startsWith("call next value for ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "CALL")),
|
|
|
- span ->
|
|
|
- span.hasName("INSERT test.JpaCustomer")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasParent(trace.getSpan(0))
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT, val -> val.startsWith("insert ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "INSERT"),
|
|
|
- equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer")));
|
|
|
+ trace.hasSpansSatisfyingExactly(
|
|
|
+ span ->
|
|
|
+ span.hasName("JpaCustomerRepository.save")
|
|
|
+ .hasKind(SpanKind.INTERNAL)
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
+ equalTo(SemanticAttributes.CODE_FUNCTION, "save")),
|
|
|
+ span ->
|
|
|
+ span.hasName("CALL test")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(
|
|
|
+ SemanticAttributes.DB_STATEMENT,
|
|
|
+ val -> val.startsWith("call next value for ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "CALL")),
|
|
|
+ span ->
|
|
|
+ span.hasName("INSERT test.JpaCustomer")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasParent(trace.getSpan(0))
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(SemanticAttributes.DB_STATEMENT, val -> val.startsWith("insert ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "INSERT"),
|
|
|
+ equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer")));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -142,29 +134,26 @@ public abstract class AbstractSpringJpaTest<
|
|
|
|
|
|
testing.waitAndAssertTraces(
|
|
|
trace ->
|
|
|
- trace
|
|
|
- .hasSize(2)
|
|
|
- .hasSpansSatisfyingExactly(
|
|
|
- span ->
|
|
|
- span.hasName("JpaCustomerRepository.findAll")
|
|
|
- .hasKind(SpanKind.INTERNAL)
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
- equalTo(SemanticAttributes.CODE_FUNCTION, "findAll")),
|
|
|
- span ->
|
|
|
- span.hasName("SELECT test.JpaCustomer")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasParent(trace.getSpan(0))
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT,
|
|
|
- val -> val.startsWith("select ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
- equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
+ trace.hasSpansSatisfyingExactly(
|
|
|
+ span ->
|
|
|
+ span.hasName("JpaCustomerRepository.findAll")
|
|
|
+ .hasKind(SpanKind.INTERNAL)
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
+ equalTo(SemanticAttributes.CODE_FUNCTION, "findAll")),
|
|
|
+ span ->
|
|
|
+ span.hasName("SELECT test.JpaCustomer")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasParent(trace.getSpan(0))
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(
|
|
|
+ SemanticAttributes.DB_STATEMENT, val -> val.startsWith("select ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
+ equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
clearData();
|
|
|
|
|
|
repo.save(customer);
|
|
@@ -182,113 +171,102 @@ public abstract class AbstractSpringJpaTest<
|
|
|
assertEquals(id(customer), savedId);
|
|
|
testing.waitAndAssertTraces(
|
|
|
trace ->
|
|
|
- trace
|
|
|
- .hasSize(3)
|
|
|
- .hasSpansSatisfyingExactly(
|
|
|
- span ->
|
|
|
- span.hasName("JpaCustomerRepository.save")
|
|
|
- .hasKind(SpanKind.INTERNAL)
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
- equalTo(SemanticAttributes.CODE_FUNCTION, "save")),
|
|
|
- span ->
|
|
|
- span.hasName("SELECT test.JpaCustomer")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasParent(trace.getSpan(0))
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT,
|
|
|
- val -> val.startsWith("select ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
- equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer")),
|
|
|
- span ->
|
|
|
- span.hasName("UPDATE test.JpaCustomer")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasParent(trace.getSpan(0))
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT,
|
|
|
- val -> val.startsWith("update ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "UPDATE"),
|
|
|
- equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
+ trace.hasSpansSatisfyingExactly(
|
|
|
+ span ->
|
|
|
+ span.hasName("JpaCustomerRepository.save")
|
|
|
+ .hasKind(SpanKind.INTERNAL)
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
+ equalTo(SemanticAttributes.CODE_FUNCTION, "save")),
|
|
|
+ span ->
|
|
|
+ span.hasName("SELECT test.JpaCustomer")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasParent(trace.getSpan(0))
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(
|
|
|
+ SemanticAttributes.DB_STATEMENT, val -> val.startsWith("select ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
+ equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer")),
|
|
|
+ span ->
|
|
|
+ span.hasName("UPDATE test.JpaCustomer")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasParent(trace.getSpan(0))
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(
|
|
|
+ SemanticAttributes.DB_STATEMENT, val -> val.startsWith("update ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "UPDATE"),
|
|
|
+ equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
clearData();
|
|
|
|
|
|
customer = findByLastName(repo, "Anonymous").get(0);
|
|
|
testing.waitAndAssertTraces(
|
|
|
trace ->
|
|
|
- trace
|
|
|
- .hasSize(2)
|
|
|
- .hasSpansSatisfyingExactly(
|
|
|
- span ->
|
|
|
- span.hasName("JpaCustomerRepository.findByLastName")
|
|
|
- .hasKind(SpanKind.INTERNAL)
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
- equalTo(SemanticAttributes.CODE_FUNCTION, "findByLastName")),
|
|
|
- span ->
|
|
|
- span.hasName("SELECT test.JpaCustomer")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasParent(trace.getSpan(0))
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT,
|
|
|
- val -> val.startsWith("select ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
- equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
+ trace.hasSpansSatisfyingExactly(
|
|
|
+ span ->
|
|
|
+ span.hasName("JpaCustomerRepository.findByLastName")
|
|
|
+ .hasKind(SpanKind.INTERNAL)
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
+ equalTo(SemanticAttributes.CODE_FUNCTION, "findByLastName")),
|
|
|
+ span ->
|
|
|
+ span.hasName("SELECT test.JpaCustomer")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasParent(trace.getSpan(0))
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(
|
|
|
+ SemanticAttributes.DB_STATEMENT, val -> val.startsWith("select ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
+ equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
clearData();
|
|
|
|
|
|
repo.delete(customer);
|
|
|
testing.waitAndAssertTraces(
|
|
|
trace ->
|
|
|
- trace
|
|
|
- .hasSize(3)
|
|
|
- .hasSpansSatisfyingExactly(
|
|
|
- span ->
|
|
|
- span.hasName("JpaCustomerRepository.delete")
|
|
|
- .hasKind(SpanKind.INTERNAL)
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
- equalTo(SemanticAttributes.CODE_FUNCTION, "delete")),
|
|
|
- span ->
|
|
|
- span.hasName("SELECT test.JpaCustomer")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasParent(trace.getSpan(0))
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT,
|
|
|
- val -> val.startsWith("select ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
- equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer")),
|
|
|
- span ->
|
|
|
- span.hasName("DELETE test.JpaCustomer")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasParent(trace.getSpan(0))
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT,
|
|
|
- val -> val.startsWith("delete ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "DELETE"),
|
|
|
- equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
+ trace.hasSpansSatisfyingExactly(
|
|
|
+ span ->
|
|
|
+ span.hasName("JpaCustomerRepository.delete")
|
|
|
+ .hasKind(SpanKind.INTERNAL)
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
+ equalTo(SemanticAttributes.CODE_FUNCTION, "delete")),
|
|
|
+ span ->
|
|
|
+ span.hasName("SELECT test.JpaCustomer")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasParent(trace.getSpan(0))
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(
|
|
|
+ SemanticAttributes.DB_STATEMENT, val -> val.startsWith("select ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
+ equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer")),
|
|
|
+ span ->
|
|
|
+ span.hasName("DELETE test.JpaCustomer")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasParent(trace.getSpan(0))
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(
|
|
|
+ SemanticAttributes.DB_STATEMENT, val -> val.startsWith("delete ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "DELETE"),
|
|
|
+ equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -301,29 +279,26 @@ public abstract class AbstractSpringJpaTest<
|
|
|
|
|
|
testing.waitAndAssertTraces(
|
|
|
trace ->
|
|
|
- trace
|
|
|
- .hasSize(2)
|
|
|
- .hasSpansSatisfyingExactly(
|
|
|
- span ->
|
|
|
- span.hasName("JpaCustomerRepository.findSpecialCustomers")
|
|
|
- .hasKind(SpanKind.INTERNAL)
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
- equalTo(SemanticAttributes.CODE_FUNCTION, "findSpecialCustomers")),
|
|
|
- span ->
|
|
|
- span.hasName("SELECT test.JpaCustomer")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasParent(trace.getSpan(0))
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT,
|
|
|
- val -> val.startsWith("select ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
- equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
+ trace.hasSpansSatisfyingExactly(
|
|
|
+ span ->
|
|
|
+ span.hasName("JpaCustomerRepository.findSpecialCustomers")
|
|
|
+ .hasKind(SpanKind.INTERNAL)
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
+ equalTo(SemanticAttributes.CODE_FUNCTION, "findSpecialCustomers")),
|
|
|
+ span ->
|
|
|
+ span.hasName("SELECT test.JpaCustomer")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasParent(trace.getSpan(0))
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(
|
|
|
+ SemanticAttributes.DB_STATEMENT, val -> val.startsWith("select ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
+ equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -347,30 +322,27 @@ public abstract class AbstractSpringJpaTest<
|
|
|
assertNotNull(expectedException);
|
|
|
testing.waitAndAssertTraces(
|
|
|
trace ->
|
|
|
- trace
|
|
|
- .hasSize(2)
|
|
|
- .hasSpansSatisfyingExactly(
|
|
|
- span ->
|
|
|
- span.hasName("JpaCustomerRepository.findOneByLastName")
|
|
|
- .hasKind(SpanKind.INTERNAL)
|
|
|
- .hasStatus(StatusData.error())
|
|
|
- .hasException(expectedException)
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
- equalTo(SemanticAttributes.CODE_FUNCTION, "findOneByLastName")),
|
|
|
- span ->
|
|
|
- span.hasName("SELECT test.JpaCustomer")
|
|
|
- .hasKind(SpanKind.CLIENT)
|
|
|
- .hasParent(trace.getSpan(0))
|
|
|
- .hasAttributesSatisfyingExactly(
|
|
|
- equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
- equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
- equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
- equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
- satisfies(
|
|
|
- SemanticAttributes.DB_STATEMENT,
|
|
|
- val -> val.startsWith("select ")),
|
|
|
- equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
- equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
+ trace.hasSpansSatisfyingExactly(
|
|
|
+ span ->
|
|
|
+ span.hasName("JpaCustomerRepository.findOneByLastName")
|
|
|
+ .hasKind(SpanKind.INTERNAL)
|
|
|
+ .hasStatus(StatusData.error())
|
|
|
+ .hasException(expectedException)
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.CODE_NAMESPACE, repoClassName),
|
|
|
+ equalTo(SemanticAttributes.CODE_FUNCTION, "findOneByLastName")),
|
|
|
+ span ->
|
|
|
+ span.hasName("SELECT test.JpaCustomer")
|
|
|
+ .hasKind(SpanKind.CLIENT)
|
|
|
+ .hasParent(trace.getSpan(0))
|
|
|
+ .hasAttributesSatisfyingExactly(
|
|
|
+ equalTo(SemanticAttributes.DB_SYSTEM, "hsqldb"),
|
|
|
+ equalTo(SemanticAttributes.DB_NAME, "test"),
|
|
|
+ equalTo(SemanticAttributes.DB_USER, "sa"),
|
|
|
+ equalTo(SemanticAttributes.DB_CONNECTION_STRING, "hsqldb:mem:"),
|
|
|
+ satisfies(
|
|
|
+ SemanticAttributes.DB_STATEMENT, val -> val.startsWith("select ")),
|
|
|
+ equalTo(SemanticAttributes.DB_OPERATION, "SELECT"),
|
|
|
+ equalTo(SemanticAttributes.DB_SQL_TABLE, "JpaCustomer"))));
|
|
|
}
|
|
|
}
|