@@ -50,6 +50,7 @@ namespace AdbcDrivers.BigQuery
5050 /// </summary>
5151 class BigQueryStatement : TracingStatement , ITokenProtectedResource , IDisposable
5252 {
53+ private const string ClassName = nameof ( BigQueryStatement ) ;
5354 readonly BigQueryConnection bigQueryConnection ;
5455 readonly CancellationRegistry cancellationRegistry ;
5556
@@ -131,6 +132,7 @@ private async Task<QueryResult> ExecuteQueryInternalAsync()
131132 getQueryResultsOptions . Timeout = TimeSpan . FromSeconds ( seconds ) ;
132133 activity ? . AddBigQueryParameterTag ( BigQueryParameters . GetQueryResultsOptionsTimeout , seconds ) ;
133134 }
135+ activity ? . AddBigQueryParameterTag ( BigQueryParameters . ClientTimeout , Client . Service . HttpClient . Timeout . Seconds ) ;
134136
135137 using JobCancellationContext cancellationContext = new JobCancellationContext ( cancellationRegistry , job ) ;
136138
@@ -140,9 +142,12 @@ private async Task<QueryResult> ExecuteQueryInternalAsync()
140142 {
141143 return await ExecuteCancellableJobAsync ( cancellationContext , activity , async ( context ) =>
142144 {
143- // if the authentication token was reset, then we need a new job with the latest token
144- context . Job = await Client . GetJobAsync ( jobReference , cancellationToken : context . CancellationToken ) . ConfigureAwait ( false ) ;
145- return await context . Job . GetQueryResultsAsync ( getQueryResultsOptions , cancellationToken : context . CancellationToken ) . ConfigureAwait ( false ) ;
145+ return await this . TraceActivityAsync ( async activity =>
146+ {
147+ // if the authentication token was reset, then we need a new job with the latest token
148+ context . Job = await Client . GetJobAsync ( jobReference , cancellationToken : context . CancellationToken ) . ConfigureAwait ( false ) ;
149+ return await context . Job . GetQueryResultsAsync ( getQueryResultsOptions , cancellationToken : context . CancellationToken ) . ConfigureAwait ( false ) ;
150+ } , ClassName + "." + nameof ( ExecuteQueryInternalAsync ) + "." + nameof ( BigQueryJob . GetQueryResultsAsync ) ) ;
146151 } ) . ConfigureAwait ( false ) ;
147152 } ;
148153
@@ -235,8 +240,11 @@ private async Task<QueryResult> ExecuteQueryInternalAsync()
235240 {
236241 return await ExecuteCancellableJobAsync ( cancellationContext , activity , async ( context ) =>
237242 {
238- // Cancelling this step may leave the server with unread streams.
239- return await GetArrowReaders ( clientMgr , table , results . TableReference . ProjectId , maxStreamCount , activity , context . CancellationToken ) . ConfigureAwait ( false ) ;
243+ return await this . TraceActivityAsync ( async activity =>
244+ {
245+ // Cancelling this step may leave the server with unread streams.
246+ return await GetArrowReaders ( clientMgr , table , results . TableReference . ProjectId , maxStreamCount , activity , context . CancellationToken ) . ConfigureAwait ( false ) ;
247+ } , ClassName + "." + nameof ( ExecuteQueryInternalAsync ) + "." + nameof ( GetArrowReaders ) ) ;
240248 } ) . ConfigureAwait ( false ) ;
241249 } ;
242250 IEnumerable < IArrowReader > readers = await ExecuteWithRetriesAsync ( getArrowReadersFunc , activity , cancellationContext . CancellationToken ) . ConfigureAwait ( false ) ;
@@ -245,7 +253,7 @@ private async Task<QueryResult> ExecuteQueryInternalAsync()
245253 IArrowArrayStream stream = new MultiArrowReader ( this , TranslateSchema ( results . Schema ) , readers , new CancellationContext ( cancellationRegistry ) ) ;
246254 activity ? . AddTag ( SemanticConventions . Db . Response . ReturnedRows , totalRows ) ;
247255 return new QueryResult ( totalRows , stream ) ;
248- } ) ;
256+ } , ClassName + "." + nameof ( ExecuteQueryInternalAsync ) ) ;
249257 }
250258
251259 private Task < QueryResult > ExecuteMetadataCommandQuery ( Activity ? activity )
@@ -706,7 +714,7 @@ public override void Cancel()
706714 this . TraceActivity ( _ =>
707715 {
708716 this . cancellationRegistry . CancelAll ( ) ;
709- } ) ;
717+ } , ClassName + "." + nameof ( Cancel ) ) ;
710718 }
711719
712720 public override void Dispose ( )
@@ -756,7 +764,7 @@ private async Task<UpdateResult> ExecuteUpdateInternalAsync()
756764
757765 activity ? . AddTag ( SemanticConventions . Db . Response . ReturnedRows , updatedRows ) ;
758766 return new UpdateResult ( updatedRows ) ;
759- } ) ;
767+ } , ClassName + "." + nameof ( ExecuteUpdateInternalAsync ) ) ;
760768 }
761769
762770 private Schema TranslateSchema ( TableSchema schema )
@@ -1166,6 +1174,7 @@ public void Dispose()
11661174
11671175 private class MultiArrowReader : TracingReader
11681176 {
1177+ private const string ClassName = BigQueryStatement . ClassName + ".MultiArrowReader" ;
11691178 private static readonly string s_assemblyName = BigQueryUtils . GetAssemblyName ( typeof ( BigQueryStatement ) ) ;
11701179 private static readonly string s_assemblyVersion = BigQueryUtils . GetAssemblyVersion ( typeof ( BigQueryStatement ) ) ;
11711180
@@ -1222,7 +1231,7 @@ public MultiArrowReader(BigQueryStatement statement, Schema schema, IEnumerable<
12221231
12231232 this . reader = null ;
12241233 }
1225- } ) ;
1234+ } , ClassName + "." + nameof ( ReadNextRecordBatchAsync ) ) ;
12261235 }
12271236
12281237 protected override void Dispose ( bool disposing )
0 commit comments