Skip to content

Commit 1691cd7

Browse files
committed
remove debug lines
1 parent ec4d529 commit 1691cd7

1 file changed

Lines changed: 4 additions & 88 deletions

File tree

java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java

Lines changed: 4 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,13 @@
4747
import java.util.List;
4848
import org.junit.jupiter.api.Test;
4949

50-
// @Tag("known_issue") // b/539615312
5150
public class ITOpenTelemetryTest extends ITBase {
5251

5352
private static final String PROJECT_ID = ServiceOptions.getDefaultProjectId();
5453
private static final String CONNECTION_URL = connectionUrl;
5554

5655
@Test
5756
public void testExecute_withOpenTelemetryGcpExporter() throws Exception {
58-
System.out.println("[DEBUG_IT] === Starting testExecute_withOpenTelemetryGcpExporter ===");
5957

6058
// Step 1: Connect with GCP Exporters enabled via DataSource
6159
DataSource ds = DataSource.fromUrl(CONNECTION_URL);
@@ -75,7 +73,6 @@ public void testExecute_withOpenTelemetryGcpExporter() throws Exception {
7573
BigQueryConnection bqConnection = connection.unwrap(BigQueryConnection.class);
7674
connectionUuid = bqConnection.getConnectionId();
7775
assertNotNull(connectionUuid, "Connection UUID should be generated");
78-
System.out.println("[DEBUG_IT] Generated connectionUuid: " + connectionUuid);
7976

8077
// Execute an in-memory array query (scans 0 bytes, extremely fast) and force pagination (3
8178
// pages)
@@ -85,9 +82,6 @@ public void testExecute_withOpenTelemetryGcpExporter() throws Exception {
8582
// Drain the result set to trigger pagination fetches
8683
}
8784
}
88-
System.out.println(
89-
"[DEBUG_IT] Query executed. Waiting for logs and traces for connectionUuid: "
90-
+ connectionUuid);
9185
}
9286

9387
// Step 2: Retrieve and assert logs, harvesting the TraceId
@@ -131,7 +125,6 @@ public void testExecute_withOpenTelemetryGcpExporter() throws Exception {
131125

132126
@Test
133127
public void testExecute_withErrorCorrelation() throws Exception {
134-
System.out.println("[DEBUG_IT] === Starting testExecute_withErrorCorrelation ===");
135128

136129
// Step 1: Connect with GCP Exporters enabled via DataSource
137130
DataSource ds = DataSource.fromUrl(CONNECTION_URL);
@@ -149,13 +142,9 @@ public void testExecute_withErrorCorrelation() throws Exception {
149142
BigQueryConnection bqConnection = connection.unwrap(BigQueryConnection.class);
150143
connectionUuid = bqConnection.getConnectionId();
151144
assertNotNull(connectionUuid, "Connection UUID should be generated");
152-
System.out.println("[DEBUG_IT] Generated connectionUuid: " + connectionUuid);
153145

154146
// Execute a query designed to fail instantly due to syntax error (compiler-level failure)
155147
assertThrows(SQLException.class, () -> statement.executeQuery("SELECT * FROM;"));
156-
System.out.println(
157-
"[DEBUG_IT] Expected SQLException caught. Waiting for logs and traces for connectionUuid: "
158-
+ connectionUuid);
159148
}
160149

161150
// Step 2: Retrieve and assert logs, harvesting the TraceId
@@ -180,7 +169,6 @@ public void testExecute_withErrorCorrelation() throws Exception {
180169

181170
@Test
182171
public void testExecute_withCustomCredentialsJson() throws Exception {
183-
System.out.println("[DEBUG_IT] === Starting testExecute_withCustomCredentialsJson ===");
184172
JsonObject authJson = getAuthJson();
185173
DataSource ds = DataSource.fromUrl(CONNECTION_URL);
186174
ds.setEnableGcpTraceExporter(true);
@@ -192,7 +180,6 @@ public void testExecute_withCustomCredentialsJson() throws Exception {
192180

193181
@Test
194182
public void testExecute_withCustomCredentialsFilePath() throws Exception {
195-
System.out.println("[DEBUG_IT] === Starting testExecute_withCustomCredentialsFilePath ===");
196183
JsonObject authJson = getAuthJson();
197184
File tempFile = File.createTempFile("auth", ".json");
198185
tempFile.deleteOnExit();
@@ -208,7 +195,6 @@ public void testExecute_withCustomCredentialsFilePath() throws Exception {
208195

209196
@Test
210197
public void testExecute_withHttpProtocol() throws Exception {
211-
System.out.println("[DEBUG_IT] === Starting testExecute_withHttpProtocol ===");
212198
JsonObject authJson = getAuthJson();
213199
System.setProperty("otel.exporter.otlp.protocol", "http/protobuf");
214200

@@ -226,7 +212,6 @@ public void testExecute_withHttpProtocol() throws Exception {
226212

227213
@Test
228214
public void testExecute_withGrpcProtocol() throws Exception {
229-
System.out.println("[DEBUG_IT] === Starting testExecute_withGrpcProtocol ===");
230215
JsonObject authJson = getAuthJson();
231216
System.setProperty("otel.exporter.otlp.protocol", "grpc");
232217

@@ -252,7 +237,6 @@ private void verifyTraceDelivery(DataSource ds) throws Exception {
252237

253238
BigQueryConnection bqConnection = connection.unwrap(BigQueryConnection.class);
254239
connectionUuid = bqConnection.getConnectionId();
255-
System.out.println("[DEBUG_IT] verifyTraceDelivery connectionUuid: " + connectionUuid);
256240

257241
String query = "SELECT 1;";
258242
try (ResultSet rs = statement.executeQuery(query)) {
@@ -321,132 +305,64 @@ private Trace verifyAndFetchTrace(String traceId) throws Exception {
321305
}
322306
}
323307

324-
private <T> T pollWithRetry(String taskDescription, java.util.concurrent.Callable<T> task)
325-
throws InterruptedException {
308+
private <T> T pollWithRetry(java.util.concurrent.Callable<T> task) throws InterruptedException {
326309
int attempts = 0;
327310
int maxAttempts = 24;
328311
long delayMs = 10000;
329312

330-
System.out.println(
331-
"[DEBUG_IT] ["
332-
+ taskDescription
333-
+ "] Starting polling (maxAttempts="
334-
+ maxAttempts
335-
+ ", delayMs="
336-
+ delayMs
337-
+ "). Waiting 10 seconds initially...");
338313
// 10 second wait for GCP to ingest data
339314
Thread.sleep(10000);
340315

341316
while (attempts < maxAttempts) {
342317
attempts++;
343-
System.out.println(
344-
"[DEBUG_IT] [" + taskDescription + "] Attempt " + attempts + "/" + maxAttempts);
345318
try {
346319
T result = task.call();
347320
if (result != null) {
348-
System.out.println(
349-
"[DEBUG_IT] ["
350-
+ taskDescription
351-
+ "] Succeeded on attempt "
352-
+ attempts
353-
+ "/"
354-
+ maxAttempts);
355321
return result;
356322
}
357323
} catch (InterruptedException e) {
358324
Thread.currentThread().interrupt();
359325
throw new RuntimeException("Test execution interrupted", e);
360326
} catch (Exception e) {
361-
System.err.println(
362-
"[DEBUG_IT] ["
363-
+ taskDescription
364-
+ "] Exception on attempt "
365-
+ attempts
366-
+ ": "
367-
+ e.getClass().getName()
368-
+ " - "
369-
+ e.getMessage());
327+
// Ignore exceptions during remote lookup and retry
370328
e.printStackTrace();
371329
}
372330
if (attempts < maxAttempts) {
373331
Thread.sleep(delayMs);
374332
}
375333
}
376-
System.err.println(
377-
"[DEBUG_IT] [" + taskDescription + "] Timed out after " + maxAttempts + " attempts.");
378334
return null;
379335
}
380336

381337
private List<LogEntry> fetchLogsWithRetry(Logging logging, String filter)
382338
throws InterruptedException {
383-
System.out.println("[DEBUG_IT] Polling GCP Cloud Logging with filter: " + filter);
384339
List<LogEntry> result =
385340
pollWithRetry(
386-
"fetchLogsWithRetry (" + filter + ")",
387341
() -> {
388342
Page<LogEntry> entriesPage =
389343
logging.listLogEntries(
390344
Logging.EntryListOption.filter(filter), Logging.EntryListOption.pageSize(50));
391345
List<LogEntry> entries = new ArrayList<>();
392346
entriesPage.iterateAll().forEach(entries::add);
393-
if (entries.isEmpty()) {
394-
System.out.println("[DEBUG_IT] -> Found 0 matching log entries.");
395-
return null;
396-
}
397-
System.out.println(
398-
"[DEBUG_IT] -> Found " + entries.size() + " matching log entries:");
399-
for (LogEntry entry : entries) {
400-
System.out.println(
401-
"[DEBUG_IT] LogEntry: logName="
402-
+ entry.getLogName()
403-
+ ", trace="
404-
+ entry.getTrace()
405-
+ ", spanId="
406-
+ entry.getSpanId()
407-
+ ", labels="
408-
+ entry.getLabels()
409-
+ ", payload="
410-
+ entry.getPayload());
411-
}
412-
return entries;
347+
return entries.isEmpty() ? null : entries;
413348
});
414349
return result != null ? result : new ArrayList<>();
415350
}
416351

417352
private Trace fetchTraceWithRetry(
418353
TraceServiceClient traceClient, String projectId, String traceId)
419354
throws InterruptedException {
420-
System.out.println(
421-
"[DEBUG_IT] Polling GCP Cloud Trace with projectId=" + projectId + ", traceId=" + traceId);
422355
return pollWithRetry(
423-
"fetchTraceWithRetry (" + traceId + ")",
424356
() -> {
425357
Trace trace = traceClient.getTrace(projectId, traceId);
426358
if (trace == null) {
427-
System.out.println("[DEBUG_IT] -> traceClient.getTrace returned null.");
428359
return null;
429360
}
430-
System.out.println(
431-
"[DEBUG_IT] -> Found trace with " + trace.getSpansCount() + " spans:");
432-
boolean foundExecuteQuery = false;
433361
for (TraceSpan span : trace.getSpansList()) {
434-
System.out.println(
435-
"[DEBUG_IT] Span: name="
436-
+ span.getName()
437-
+ ", spanId="
438-
+ span.getSpanId()
439-
+ ", parentSpanId="
440-
+ span.getParentSpanId());
441362
if (span.getName().equals("BigQueryStatement.executeQuery")) {
442-
foundExecuteQuery = true;
363+
return trace;
443364
}
444365
}
445-
if (foundExecuteQuery) {
446-
return trace;
447-
}
448-
System.out.println(
449-
"[DEBUG_IT] -> Trace present, but 'BigQueryStatement.executeQuery' span not yet found.");
450366
return null;
451367
});
452368
}

0 commit comments

Comments
 (0)