ihji commented on a change in pull request #12609:
URL: https://github.com/apache/beam/pull/12609#discussion_r477695112



##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImpl.java
##########
@@ -1014,34 +1021,33 @@ private static boolean nextBackOff(Sleeper sleeper, 
BackOff backoff) throws Inte
   }
 
   /** Returns a BigQuery client builder using the specified {@link 
BigQueryOptions}. */
-  private static Bigquery.Builder newBigQueryClient(BigQueryOptions options) {
+  private static Bigquery.Builder newBigQueryClient(
+      BigQueryOptions options, @Nullable Histogram requestLatencies) {
     RetryHttpRequestInitializer httpRequestInitializer =
         new RetryHttpRequestInitializer(ImmutableList.of(404));
     httpRequestInitializer.setCustomErrors(createBigQueryClientCustomErrors());
     httpRequestInitializer.setWriteTimeout(options.getHTTPWriteTimeout());
+    ImmutableList.Builder<HttpRequestInitializer> initBuilder = 
ImmutableList.builder();
+    Credentials credential = options.getGcpCredential();
+    initBuilder.add(
+        credential == null
+            ? new NullCredentialInitializer()
+            : new HttpCredentialsAdapter(credential));
+    // Do not log 404. It clutters the output and is possibly even required by 
the
+    // caller.
+    initBuilder.add(httpRequestInitializer);
+    if (requestLatencies != null) {
+      initBuilder.add(new 
LatencyRecordingHttpRequestInitializer(requestLatencies));
+    }
+    HttpRequestInitializer chainInitializer =

Review comment:
       I didn't observe any performance difference before and after applying 
this change. Recording is done in a constant time and percentile estimation 
only requires a linear time depending on the number of buckets (which is also 
small like few thousands).




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to