@@ -6489,6 +6489,14 @@ public void testLocation() throws Exception {
64896489
64906490 assertThat (location ).isNotEqualTo (wrongLocation );
64916491
6492+ Tracer tracer = otel .getTracer ("Test Tracer" );
6493+ bigquery =
6494+ bigquery .getOptions ().toBuilder ()
6495+ .setEnableOpenTelemetryTracing (true )
6496+ .setOpenTelemetryTracer (tracer )
6497+ .build ()
6498+ .getService ();
6499+
64926500 Dataset dataset =
64936501 bigquery .create (
64946502 DatasetInfo .newBuilder ("locationset_" + UUID .randomUUID ().toString ().replace ("-" , "_" ))
@@ -6565,6 +6573,11 @@ public void testLocation() throws Exception {
65656573 bigquery .writer (
65666574 JobId .newBuilder ().setLocation (location ).build (), writeChannelConfiguration )) {
65676575 writer .write (ByteBuffer .wrap ("foo" .getBytes ()));
6576+ assertEquals (
6577+ OTEL_ATTRIBUTES
6578+ .get ("com.google.cloud.bigquery.TableDataWriteChannel.open" )
6579+ .get (AttributeKey .stringKey ("bq.job.location" )),
6580+ location );
65686581 }
65696582
65706583 try {
@@ -6577,6 +6590,12 @@ public void testLocation() throws Exception {
65776590 }
65786591 } finally {
65796592 bigquery .delete (dataset .getDatasetId (), DatasetDeleteOption .deleteContents ());
6593+ bigquery =
6594+ bigquery .getOptions ().toBuilder ()
6595+ .setEnableOpenTelemetryTracing (false )
6596+ .setOpenTelemetryTracer (null )
6597+ .build ()
6598+ .getService ();
65806599 }
65816600 }
65826601
@@ -7661,6 +7680,7 @@ public void testOpenTelemetryTracingTables() {
76617680 assertEquals (
76627681 OTEL_PARENT_SPAN_IDS .get ("com.google.cloud.bigquery.BigQuery.updateTable" ),
76637682 OTEL_PARENT_SPAN_ID );
7683+ assertTrue (bigquery .delete (updatedTable .getTableId ()));
76647684 }
76657685
76667686 @ Test
@@ -7680,6 +7700,9 @@ public void testOpenTelemetryTracingQuery() throws InterruptedException {
76807700 assertNull (tableResult .getJobId ());
76817701
76827702 assertNotNull (OTEL_ATTRIBUTES .get ("com.google.cloud.bigquery.BigQuery.queryRpc" ));
7703+ assertNotNull (
7704+ OTEL_ATTRIBUTES .get ("com.google.cloud.bigquery.BigQueryRetryHelper.runWithRetries" ));
7705+ assertTrue (OTEL_ATTRIBUTES .containsKey ("com.google.cloud.bigquery.BigQuery.query" ));
76837706
76847707 // Query job
76857708 String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID .getTable ();
@@ -7694,5 +7717,7 @@ public void testOpenTelemetryTracingQuery() throws InterruptedException {
76947717 assertNotNull (OTEL_ATTRIBUTES .get ("com.google.cloud.bigquery.BigQuery.getQueryResults" ));
76957718 assertNotNull (OTEL_ATTRIBUTES .get ("com.google.cloud.bigquery.BigQuery.listTableData" ));
76967719 assertNotNull (OTEL_ATTRIBUTES .get ("com.google.cloud.bigquery.BigQuery.createJob" ));
7720+ assertTrue (OTEL_ATTRIBUTES .containsKey ("com.google.cloud.bigquery.Job.getQueryResults" ));
7721+ assertTrue (OTEL_ATTRIBUTES .containsKey ("com.google.cloud.bigquery.Job.waitForQueryResults" ));
76977722 }
76987723}
0 commit comments