@@ -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