@@ -48,16 +48,6 @@ public class ITOpenTelemetryTest {
4848 "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=%s;OAuthType=3;Timeout=3600;" ,
4949 PROJECT_ID );
5050
51- private static class TelemetryContext {
52- final String traceId ;
53- final String spanId ;
54-
55- TelemetryContext (String traceId , String spanId ) {
56- this .traceId = traceId ;
57- this .spanId = spanId ;
58- }
59- }
60-
6151 @ Test
6252 public void testExecute_withOpenTelemetryGcpExporter () throws Exception {
6353
@@ -91,11 +81,11 @@ public void testExecute_withOpenTelemetryGcpExporter() throws Exception {
9181 }
9282 }
9383
94- // Step 2: Retrieve and assert logs
95- TelemetryContext telCtx = verifyAndFetchLogs (connectionUuid );
84+ // Step 2: Retrieve and assert logs, harvesting the TraceId
85+ String traceId = verifyAndFetchLogs (connectionUuid );
9686
9787 // Step 3: Query Cloud Trace and assert parent-child hierarchy
98- Trace trace = verifyAndFetchTrace (telCtx . traceId );
88+ Trace trace = verifyAndFetchTrace (traceId );
9989
10090 boolean foundParentExecuteQuery = false ;
10191 boolean foundChildSdkSpans = false ;
@@ -154,11 +144,11 @@ public void testExecute_withErrorCorrelation() throws Exception {
154144 assertThrows (SQLException .class , () -> statement .executeQuery ("SELECT * FROM;" ));
155145 }
156146
157- // Step 2: Retrieve and assert logs
158- TelemetryContext telCtx = verifyAndFetchLogs (connectionUuid );
147+ // Step 2: Retrieve and assert logs, harvesting the TraceId
148+ String traceId = verifyAndFetchLogs (connectionUuid );
159149
160150 // Step 3: Query Cloud Trace and assert span status is ERROR
161- Trace trace = verifyAndFetchTrace (telCtx . traceId );
151+ Trace trace = verifyAndFetchTrace (traceId );
162152
163153 boolean foundParentExecuteQuery = false ;
164154
@@ -174,7 +164,7 @@ public void testExecute_withErrorCorrelation() throws Exception {
174164 "Traces must contain JDBC parent span 'BigQueryStatement.executeQuery'" );
175165 }
176166
177- private TelemetryContext verifyAndFetchLogs (String connectionUuid ) throws Exception {
167+ private String verifyAndFetchLogs (String connectionUuid ) throws Exception {
178168 try (Logging logging =
179169 LoggingOptions .newBuilder ().setProjectId (PROJECT_ID ).build ().getService ()) {
180170 String filter =
@@ -199,7 +189,7 @@ private TelemetryContext verifyAndFetchLogs(String connectionUuid) throws Except
199189 assertEquals (connectionUuid , entry .getLabels ().get ("jdbc.connection_id" ));
200190 }
201191
202- return new TelemetryContext ( traceId , hexSpanId ) ;
192+ return traceId ;
203193 }
204194 }
205195
0 commit comments