Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Commit b8bb754

Browse files
committed
fix IT test failures
1 parent 5e217e8 commit b8bb754

2 files changed

Lines changed: 27 additions & 31 deletions

File tree

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/BigQueryReadClient.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ protected BigQueryReadClient(BigQueryReadSettings settings) throws IOException {
131131
this.settings = settings;
132132
this.stub =
133133
EnhancedBigQueryReadStub.create(
134-
settings.getTypedStubSettings(), settings.getReadRowsRetryAttemptListener());
134+
settings.getTypedStubSettings(),
135+
settings.getReadRowsRetryAttemptListener(),
136+
settings.isOpenTelemetryEnabled());
135137
}
136138

137139
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
@@ -241,14 +243,12 @@ public final ReadSession createReadSession(CreateReadSessionRequest request) {
241243
.setAttribute(
242244
"bq.storage.read_session.request.parent", getFieldAsString(request.getParent()))
243245
.setAttribute(
244-
"bq.storage.read_session.request.max_stream_count",
245-
getFieldAsString(request.getMaxStreamCount()))
246+
"bq.storage.read_session.request.max_stream_count", request.getMaxStreamCount())
246247
.setAttribute(
247248
"bq.storage.read_session.request.preferred_min_stream_count",
248-
getFieldAsString(request.getPreferredMinStreamCount()))
249+
request.getPreferredMinStreamCount())
249250
.setAttribute(
250-
"bq.storage.read_session.request.serialized_size",
251-
getFieldAsString(request.getSerializedSize()))
251+
"bq.storage.read_session.request.serialized_size", request.getSerializedSize())
252252
.setAllAttributes(otelAttributesFrom(request.getReadSession()))
253253
.startSpan();
254254
}
@@ -548,18 +548,14 @@ private Attributes otelAttributesFrom(ReadSession readSession) {
548548
"bq.storage.read_session.serialized_size",
549549
getFieldAsString(readSession.getSerializedSize()))
550550
.put("bq.storage.read_session.table", getFieldAsString(readSession.getTable()))
551-
.put(
552-
"bq.storage.read_session.estimated_row_count",
553-
getFieldAsString(readSession.getEstimatedRowCount()))
551+
.put("bq.storage.read_session.estimated_row_count", readSession.getEstimatedRowCount())
554552
.put(
555553
"bq.storage.read_session.estimated_total_bytes_scanned",
556-
getFieldAsString(readSession.getEstimatedTotalBytesScanned()))
554+
readSession.getEstimatedTotalBytesScanned())
557555
.put(
558556
"bq.storage.read_session.estimated_total_physical_bytes",
559-
getFieldAsString(readSession.getEstimatedTotalPhysicalFileSize()))
560-
.put(
561-
"bq.storage.read_session.streams_count",
562-
getFieldAsString(readSession.getStreamsCount()))
557+
readSession.getEstimatedTotalPhysicalFileSize())
558+
.put("bq.storage.read_session.streams_count", readSession.getStreamsCount())
563559
.put("bq.storage.read_session.trace_id", getFieldAsString(readSession.getTraceId()))
564560
.put("bq.storage.read_session.expire_time", getFieldAsString(readSession.getExpireTime()))
565561
.build();

google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryStorageTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ public class ITBigQueryStorageTest {
469469
new HashMap<String, Map<AttributeKey<?>, Object>>();
470470
private static final Map<String, String> OTEL_PARENT_SPAN_IDS = new HashMap<>();
471471
private static final Map<String, String> OTEL_SPAN_IDS_TO_NAMES = new HashMap<>();
472-
private static final String OTEL_PARENT_SPAN_ID = "0000000000000000";
473472

474473
private static class TestSpanExporter implements io.opentelemetry.sdk.trace.export.SpanExporter {
475474
@Override
@@ -1600,34 +1599,30 @@ public void testUniverseDomainWithMatchingDomain() throws IOException {
16001599
}
16011600

16021601
@Test
1603-
public void testSimpleReadWithOtelTracing() {
1604-
client.enableOpenTelemetryTracing();
1602+
public void testSimpleReadWithOtelTracing() throws IOException {
1603+
BigQueryReadSettings otelSettings =
1604+
BigQueryReadSettings.newBuilder().setEnableOpenTelemetryTracing(true).build();
1605+
BigQueryReadClient otelClient = BigQueryReadClient.create(otelSettings);
1606+
16051607
String table =
16061608
BigQueryResource.FormatTableResource(
16071609
/* projectId= */ "bigquery-public-data",
16081610
/* datasetId= */ "samples",
16091611
/* tableId= */ "shakespeare");
16101612

16111613
ReadSession session =
1612-
client.createReadSession(
1614+
otelClient.createReadSession(
16131615
/* parent= */ parentProjectId,
16141616
/* readSession= */ ReadSession.newBuilder()
16151617
.setTable(table)
16161618
.setDataFormat(DataFormat.AVRO)
16171619
.build(),
16181620
/* maxStreamCount= */ 1);
1619-
assertEquals(
1620-
String.format(
1621-
"Did not receive expected number of streams for table '%s' CreateReadSession"
1622-
+ " response:%n%s",
1623-
table, session.toString()),
1624-
1,
1625-
session.getStreamsCount());
16261621

16271622
ReadRowsRequest readRowsRequest =
16281623
ReadRowsRequest.newBuilder().setReadStream(session.getStreams(0).getName()).build();
16291624

1630-
ServerStream<ReadRowsResponse> stream = client.readRowsCallable().call(readRowsRequest);
1625+
ServerStream<ReadRowsResponse> stream = otelClient.readRowsCallable().call(readRowsRequest);
16311626

16321627
assertNotNull(
16331628
OTEL_ATTRIBUTES.get("com.google.cloud.bigquery.storage.v1.read.createReadSession"));
@@ -1647,12 +1642,17 @@ public void testSimpleReadWithOtelTracing() {
16471642
OTEL_PARENT_SPAN_IDS.get(
16481643
"com.google.cloud.bigquery.storage.v1.read.createReadSessionCallable")),
16491644
"com.google.cloud.bigquery.storage.v1.read.createReadSession");
1645+
1646+
Map<AttributeKey<?>, Object> createReadSessionMap =
1647+
OTEL_ATTRIBUTES.get("com.google.cloud.bigquery.storage.v1.read.createReadSession");
1648+
assertNotNull(createReadSessionMap);
1649+
assertNotNull(
1650+
createReadSessionMap.get(
1651+
AttributeKey.longKey("bq.storage.read_session.request.max_stream_count")));
16501652
assertEquals(
1651-
OTEL_ATTRIBUTES
1652-
.get("com.google.cloud.bigquery.storage.v1.read.createReadSession")
1653-
.get("bq.storage.read_session.request.max_stream_count"),
1654-
1);
1655-
client.disableOpenTelemetryTracing();
1653+
createReadSessionMap.get(
1654+
AttributeKey.longKey("bq.storage.read_session.request.max_stream_count")),
1655+
1L);
16561656
}
16571657

16581658
public void testUniverseDomain() throws IOException {

0 commit comments

Comments
 (0)