Run tests with latest spring data version
MODIFY
instrumentation/spring/spring-data-1.8/javaagent/spring-data-1.8-javaagent.gradle
instrumentation/spring/spring-data-1.8/javaagent/spring-data-1.8-javaagent.gradle
@@ -33,9 +33,8 @@ dependencies {
testInstrumentation project(':instrumentation:jdbc:javaagent')
testImplementation group: 'com.mysema.querydsl', name: 'querydsl-jpa', version: '3.7.4'
testImplementation group: 'org.hsqldb', name: 'hsqldb', version: '2.0.0'
- testImplementation group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.3.0.Final'
+ testLibrary group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.3.0.Final'
- latestDepTestLibrary group: 'org.springframework.data', name: 'spring-data-jpa', version: '(,2.4.0)'
- latestDepTestLibrary group: 'org.springframework', name: 'spring-context', version: '+'
+ latestDepTestLibrary group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.+'
}

MODIFY
instrumentation/spring/spring-data-1.8/javaagent/src/test/groovy/SpringJpaTest.groovy
instrumentation/spring/spring-data-1.8/javaagent/src/test/groovy/SpringJpaTest.groovy
@@ -9,6 +9,7 @@ import static io.opentelemetry.instrumentation.test.utils.TraceUtils.runUnderTra
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
+import org.hibernate.Version
import org.springframework.context.annotation.AnnotationConfigApplicationContext
import spring.jpa.JpaCustomer
import spring.jpa.JpaCustomerRepository
@@ -42,6 +43,7 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
}
def "test CRUD"() {
+ def isHibernate4 = Version.getVersionString().startsWith("4.")
// moved inside test -- otherwise, miss the opportunity to instrument
def context = new AnnotationConfigApplicationContext(JpaPersistenceConfig)
def repo = context.getBean(JpaCustomerRepository)
@@ -89,14 +91,31 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
then:
customer.id != null
assertTraces(1) {
- trace(0, 2) {
+ trace(0, 2 + (isHibernate4 ? 0 : 1)) {
span(0) {
name "CrudRepository.save"
kind INTERNAL
attributes {
}
}
- span(1) { // insert
+ def offset = 0
+ // hibernate5 has extra span
+ if (!isHibernate4) {
+ offset = 1
+ span(1) {
+ name "test"
+ kind CLIENT
+ childOf span(0)
+ attributes {
+ "${SemanticAttributes.DB_SYSTEM.key}" "hsqldb"
+ "${SemanticAttributes.DB_NAME.key}" "test"
+ "${SemanticAttributes.DB_USER.key}" "sa"
+ "${SemanticAttributes.DB_CONNECTION_STRING.key}" "hsqldb:mem:"
+ "${SemanticAttributes.DB_STATEMENT.key}" "call next value for hibernate_sequence"
+ }
+ }
+ }
+ span(1 + offset) { // insert
name "INSERT test.JpaCustomer"
kind CLIENT
childOf span(0)

Run tests with latest spring data version (#2927)