File tree Expand file tree Collapse file tree 2 files changed +25
-17
lines changed
instrumentation/hibernate/hibernate-reactive-1.0/javaagent
src/hibernateReactive1Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/reactive/v1_0 Expand file tree Collapse file tree 2 files changed +25
-17
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ testing {
3838 implementation(" org.hibernate.reactive:hibernate-reactive-core:1.0.0.Final" )
3939 implementation(" io.vertx:vertx-pg-client:4.1.5" )
4040 }
41+ compileOnly(" io.vertx:vertx-codegen:4.1.5" )
4142 }
4243 }
4344
Original file line number Diff line number Diff line change 1818import io .opentelemetry .api .trace .SpanKind ;
1919import io .opentelemetry .instrumentation .testing .junit .AgentInstrumentationExtension ;
2020import io .opentelemetry .instrumentation .testing .junit .InstrumentationExtension ;
21+ import io .vertx .core .Vertx ;
2122import java .time .Duration ;
23+ import java .util .concurrent .CountDownLatch ;
2224import java .util .concurrent .TimeUnit ;
2325import javax .persistence .EntityManagerFactory ;
2426import javax .persistence .Persistence ;
@@ -117,23 +119,28 @@ void testMutiny() {
117119
118120 @ Test
119121 void testStage () throws Exception {
120- testing
121- .runWithSpan (
122- "parent" ,
123- () ->
124- stageSessionFactory
125- .withSession (
126- session -> {
127- if (!Span .current ().getSpanContext ().isValid ()) {
128- throw new IllegalStateException ("missing parent span" );
129- }
130-
131- return session
132- .find (Value .class , 1L )
133- .thenAccept (value -> testing .runWithSpan ("callback" , () -> {}));
134- })
135- .toCompletableFuture ())
136- .get (30 , TimeUnit .SECONDS );
122+ CountDownLatch latch = new CountDownLatch (1 );
123+ testing .runWithSpan (
124+ "parent" ,
125+ () ->
126+ Vertx .vertx ()
127+ .getOrCreateContext ()
128+ .runOnContext (
129+ event ->
130+ stageSessionFactory
131+ .withSession (
132+ session -> {
133+ if (!Span .current ().getSpanContext ().isValid ()) {
134+ throw new IllegalStateException ("missing parent span" );
135+ }
136+
137+ return session
138+ .find (Value .class , 1L )
139+ .thenAccept (
140+ value -> testing .runWithSpan ("callback" , () -> {}));
141+ })
142+ .thenAccept (unused -> latch .countDown ())));
143+ latch .await (30 , TimeUnit .SECONDS );
137144
138145 assertTrace ();
139146 }
You can’t perform that action at this time.
0 commit comments