33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6+
67import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
78import io.opentelemetry.semconv.incubating.DbIncubatingAttributes
89import org.hibernate.Version
@@ -14,6 +15,7 @@ import spring.jpa.PersistenceConfig
1415
1516import static io.opentelemetry.api.trace.SpanKind.CLIENT
1617import static io.opentelemetry.api.trace.SpanKind.INTERNAL
18+ import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable
1719
1820class SpringJpaTest extends AgentInstrumentationSpecification {
1921
@@ -62,12 +64,12 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
6264 childOf span(1 )
6365 attributes {
6466 " $DbIncubatingAttributes . DB_SYSTEM " " hsqldb"
65- " $DbIncubatingAttributes . DB_NAME " " test"
67+ " ${ maybeStable( DbIncubatingAttributes.DB_NAME) } " " test"
6668 " $DbIncubatingAttributes . DB_USER " " sa"
6769 " $DbIncubatingAttributes . DB_CONNECTION_STRING " " hsqldb:mem:"
68- " $DbIncubatingAttributes . DB_STATEMENT " ~/ select ([^.]+)\. id([^,]*),([^.]+)\. firstName([^,]*),([^.]+)\. lastName(.*)from Customer(.*)/
69- " $DbIncubatingAttributes . DB_OPERATION " " SELECT"
70- " $DbIncubatingAttributes . DB_SQL_TABLE " " Customer"
70+ " ${ maybeStable( DbIncubatingAttributes.DB_STATEMENT) } " ~/ select ([^.]+)\. id([^,]*),([^.]+)\. firstName([^,]*),([^.]+)\. lastName(.*)from Customer(.*)/
71+ " ${ maybeStable( DbIncubatingAttributes.DB_OPERATION) } " " SELECT"
72+ " ${ maybeStable( DbIncubatingAttributes.DB_SQL_TABLE) } " " Customer"
7173 }
7274 }
7375 span(3 ) {
@@ -118,11 +120,11 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
118120 childOf span(1 )
119121 attributes {
120122 " $DbIncubatingAttributes . DB_SYSTEM " " hsqldb"
121- " $DbIncubatingAttributes . DB_NAME " " test"
123+ " ${ maybeStable( DbIncubatingAttributes.DB_NAME) } " " test"
122124 " $DbIncubatingAttributes . DB_USER " " sa"
123- " $DbIncubatingAttributes . DB_STATEMENT " " call next value for Customer_SEQ"
125+ " ${ maybeStable( DbIncubatingAttributes.DB_STATEMENT) } " " call next value for Customer_SEQ"
124126 " $DbIncubatingAttributes . DB_CONNECTION_STRING " " hsqldb:mem:"
125- " $DbIncubatingAttributes . DB_OPERATION " " CALL"
127+ " ${ maybeStable( DbIncubatingAttributes.DB_OPERATION) } " " CALL"
126128 }
127129 }
128130 span(3 ) {
@@ -139,12 +141,12 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
139141 childOf span(3 )
140142 attributes {
141143 " $DbIncubatingAttributes . DB_SYSTEM " " hsqldb"
142- " $DbIncubatingAttributes . DB_NAME " " test"
144+ " ${ maybeStable( DbIncubatingAttributes.DB_NAME) } " " test"
143145 " $DbIncubatingAttributes . DB_USER " " sa"
144146 " $DbIncubatingAttributes . DB_CONNECTION_STRING " " hsqldb:mem:"
145- " $DbIncubatingAttributes . DB_STATEMENT " ~/ insert into Customer \( .*\) values \( .*\) /
146- " $DbIncubatingAttributes . DB_OPERATION " " INSERT"
147- " $DbIncubatingAttributes . DB_SQL_TABLE " " Customer"
147+ " ${ maybeStable( DbIncubatingAttributes.DB_STATEMENT) } " ~/ insert into Customer \( .*\) values \( .*\) /
148+ " ${ maybeStable( DbIncubatingAttributes.DB_OPERATION) } " " INSERT"
149+ " ${ maybeStable( DbIncubatingAttributes.DB_SQL_TABLE) } " " Customer"
148150 }
149151 }
150152 } else {
@@ -154,12 +156,12 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
154156 childOf span(1 )
155157 attributes {
156158 " $DbIncubatingAttributes . DB_SYSTEM " " hsqldb"
157- " $DbIncubatingAttributes . DB_NAME " " test"
159+ " ${ maybeStable( DbIncubatingAttributes.DB_NAME) } " " test"
158160 " $DbIncubatingAttributes . DB_USER " " sa"
159161 " $DbIncubatingAttributes . DB_CONNECTION_STRING " " hsqldb:mem:"
160- " $DbIncubatingAttributes . DB_STATEMENT " ~/ insert into Customer \( .*\) values \( .*\) /
161- " $DbIncubatingAttributes . DB_OPERATION " " INSERT"
162- " $DbIncubatingAttributes . DB_SQL_TABLE " " Customer"
162+ " ${ maybeStable( DbIncubatingAttributes.DB_STATEMENT) } " ~/ insert into Customer \( .*\) values \( .*\) /
163+ " ${ maybeStable( DbIncubatingAttributes.DB_OPERATION) } " " INSERT"
164+ " ${ maybeStable( DbIncubatingAttributes.DB_SQL_TABLE) } " " Customer"
163165 }
164166 }
165167 span(3 ) {
@@ -209,12 +211,12 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
209211 kind CLIENT
210212 attributes {
211213 " $DbIncubatingAttributes . DB_SYSTEM " " hsqldb"
212- " $DbIncubatingAttributes . DB_NAME " " test"
214+ " ${ maybeStable( DbIncubatingAttributes.DB_NAME) } " " test"
213215 " $DbIncubatingAttributes . DB_USER " " sa"
214216 " $DbIncubatingAttributes . DB_CONNECTION_STRING " " hsqldb:mem:"
215- " $DbIncubatingAttributes . DB_STATEMENT " ~/ select ([^.]+)\. id([^,]*),([^.]+)\. firstName([^,]*),([^.]+)\. lastName (.*)from Customer (.*)where ([^.]+)\. id( ?)=( ?)\? /
216- " $DbIncubatingAttributes . DB_OPERATION " " SELECT"
217- " $DbIncubatingAttributes . DB_SQL_TABLE " " Customer"
217+ " ${ maybeStable( DbIncubatingAttributes.DB_STATEMENT) } " ~/ select ([^.]+)\. id([^,]*),([^.]+)\. firstName([^,]*),([^.]+)\. lastName (.*)from Customer (.*)where ([^.]+)\. id( ?)=( ?)\? /
218+ " ${ maybeStable( DbIncubatingAttributes.DB_OPERATION) } " " SELECT"
219+ " ${ maybeStable( DbIncubatingAttributes.DB_SQL_TABLE) } " " Customer"
218220 }
219221 }
220222 span(3 ) {
@@ -230,12 +232,12 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
230232 kind CLIENT
231233 attributes {
232234 " $DbIncubatingAttributes . DB_SYSTEM " " hsqldb"
233- " $DbIncubatingAttributes . DB_NAME " " test"
235+ " ${ maybeStable( DbIncubatingAttributes.DB_NAME) } " " test"
234236 " $DbIncubatingAttributes . DB_USER " " sa"
235237 " $DbIncubatingAttributes . DB_CONNECTION_STRING " " hsqldb:mem:"
236- " $DbIncubatingAttributes . DB_STATEMENT " ~/ update Customer set firstName=\? ,(.*)lastName=\? where id=\? /
237- " $DbIncubatingAttributes . DB_OPERATION " " UPDATE"
238- " $DbIncubatingAttributes . DB_SQL_TABLE " " Customer"
238+ " ${ maybeStable( DbIncubatingAttributes.DB_STATEMENT) } " ~/ update Customer set firstName=\? ,(.*)lastName=\? where id=\? /
239+ " ${ maybeStable( DbIncubatingAttributes.DB_OPERATION) } " " UPDATE"
240+ " ${ maybeStable( DbIncubatingAttributes.DB_SQL_TABLE) } " " Customer"
239241 }
240242 }
241243 }
@@ -273,12 +275,12 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
273275 childOf span(1 )
274276 attributes {
275277 " $DbIncubatingAttributes . DB_SYSTEM " " hsqldb"
276- " $DbIncubatingAttributes . DB_NAME " " test"
278+ " ${ maybeStable( DbIncubatingAttributes.DB_NAME) } " " test"
277279 " $DbIncubatingAttributes . DB_USER " " sa"
278280 " $DbIncubatingAttributes . DB_CONNECTION_STRING " " hsqldb:mem:"
279- " $DbIncubatingAttributes . DB_STATEMENT " ~/ select ([^.]+)\. id([^,]*),([^.]+)\. firstName([^,]*),([^.]+)\. lastName (.*)from Customer (.*)(where ([^.]+)\. lastName( ?)=( ?)\? |)/
280- " $DbIncubatingAttributes . DB_OPERATION " " SELECT"
281- " $DbIncubatingAttributes . DB_SQL_TABLE " " Customer"
281+ " ${ maybeStable( DbIncubatingAttributes.DB_STATEMENT) } " ~/ select ([^.]+)\. id([^,]*),([^.]+)\. firstName([^,]*),([^.]+)\. lastName (.*)from Customer (.*)(where ([^.]+)\. lastName( ?)=( ?)\? |)/
282+ " ${ maybeStable( DbIncubatingAttributes.DB_OPERATION) } " " SELECT"
283+ " ${ maybeStable( DbIncubatingAttributes.DB_SQL_TABLE) } " " Customer"
282284 }
283285 }
284286 }
@@ -317,12 +319,12 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
317319 childOf span(1 )
318320 attributes {
319321 " $DbIncubatingAttributes . DB_SYSTEM " " hsqldb"
320- " $DbIncubatingAttributes . DB_NAME " " test"
322+ " ${ maybeStable( DbIncubatingAttributes.DB_NAME) } " " test"
321323 " $DbIncubatingAttributes . DB_USER " " sa"
322324 " $DbIncubatingAttributes . DB_CONNECTION_STRING " " hsqldb:mem:"
323- " $DbIncubatingAttributes . DB_STATEMENT " ~/ select ([^.]+)\. id([^,]*),([^.]+)\. firstName([^,]*),([^.]+)\. lastName (.*)from Customer (.*)where ([^.]+)\. id( ?)=( ?)\? /
324- " $DbIncubatingAttributes . DB_OPERATION " " SELECT"
325- " $DbIncubatingAttributes . DB_SQL_TABLE " " Customer"
325+ " ${ maybeStable( DbIncubatingAttributes.DB_STATEMENT) } " ~/ select ([^.]+)\. id([^,]*),([^.]+)\. firstName([^,]*),([^.]+)\. lastName (.*)from Customer (.*)where ([^.]+)\. id( ?)=( ?)\? /
326+ " ${ maybeStable( DbIncubatingAttributes.DB_OPERATION) } " " SELECT"
327+ " ${ maybeStable( DbIncubatingAttributes.DB_SQL_TABLE) } " " Customer"
326328 }
327329 }
328330 }
@@ -342,12 +344,12 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
342344 childOf span(1 )
343345 attributes {
344346 " $DbIncubatingAttributes . DB_SYSTEM " " hsqldb"
345- " $DbIncubatingAttributes . DB_NAME " " test"
347+ " ${ maybeStable( DbIncubatingAttributes.DB_NAME) } " " test"
346348 " $DbIncubatingAttributes . DB_USER " " sa"
347349 " $DbIncubatingAttributes . DB_CONNECTION_STRING " " hsqldb:mem:"
348- " $DbIncubatingAttributes . DB_STATEMENT " ~/ select ([^.]+)\. id([^,]*),([^.]+)\. firstName([^,]*),([^.]+)\. lastName (.*)from Customer (.*)where ([^.]+)\. id( ?)=( ?)\? /
349- " $DbIncubatingAttributes . DB_OPERATION " " SELECT"
350- " $DbIncubatingAttributes . DB_SQL_TABLE " " Customer"
350+ " ${ maybeStable( DbIncubatingAttributes.DB_STATEMENT) } " ~/ select ([^.]+)\. id([^,]*),([^.]+)\. firstName([^,]*),([^.]+)\. lastName (.*)from Customer (.*)where ([^.]+)\. id( ?)=( ?)\? /
351+ " ${ maybeStable( DbIncubatingAttributes.DB_OPERATION) } " " SELECT"
352+ " ${ maybeStable( DbIncubatingAttributes.DB_SQL_TABLE) } " " Customer"
351353 }
352354 }
353355 }
@@ -372,12 +374,12 @@ class SpringJpaTest extends AgentInstrumentationSpecification {
372374 kind CLIENT
373375 attributes {
374376 " $DbIncubatingAttributes . DB_SYSTEM " " hsqldb"
375- " $DbIncubatingAttributes . DB_NAME " " test"
377+ " ${ maybeStable( DbIncubatingAttributes.DB_NAME) } " " test"
376378 " $DbIncubatingAttributes . DB_USER " " sa"
377379 " $DbIncubatingAttributes . DB_CONNECTION_STRING " " hsqldb:mem:"
378- " $DbIncubatingAttributes . DB_STATEMENT " " delete from Customer where id=?"
379- " $DbIncubatingAttributes . DB_OPERATION " " DELETE"
380- " $DbIncubatingAttributes . DB_SQL_TABLE " " Customer"
380+ " ${ maybeStable( DbIncubatingAttributes.DB_STATEMENT) } " " delete from Customer where id=?"
381+ " ${ maybeStable( DbIncubatingAttributes.DB_OPERATION) } " " DELETE"
382+ " ${ maybeStable( DbIncubatingAttributes.DB_SQL_TABLE) } " " Customer"
381383 }
382384 }
383385 }
0 commit comments