You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/08/26 02:29:16 UTC

[GitHub] [beam] chamikaramj commented on a change in pull request #12609: [BEAM-10699] Logging BigQuery streaming insert tail latencies

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



##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/util/Histogram.java
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.util;
+
+import java.math.RoundingMode;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.math.DoubleMath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** A histogram that supports estimated percentile with linear interpolation. */
+public class Histogram {

Review comment:
       Please add backwards compatibility warnings to this so that we can remove this without breaking users.
   Also, could you clarify why we could not use an existing implementation ?

##########
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:
       Did you confirm that there's no performance impact for the default case due to new HTTP request initializer ?




----------------------------------------------------------------
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:
users@infra.apache.org