m-trieu commented on code in PR #30320:
URL: https://github.com/apache/beam/pull/30320#discussion_r1500091087


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +338,127 @@ public static void reportFailedRPCMetrics(
     updateRpcLatencyMetric(c, method);
   }
 
+  /**
+   * Metrics of a batch of InsertAll RPCs. Member variables are thread safe; 
however, this class
+   * does not have atomicity across member variables.
+   *
+   * <p>Expected usage: A number of threads update an instance of this class 
with the member
+   * methods. Afterwards, a single thread should read call {@code 
updateStreamingInsertsMetrics} to
+   * export metrics to the underlying {@code perWorkerMetrics} container. 
Afterwards, metrics should
+   * not be written/read from this object.
+   */
+  @AutoValue
+  abstract static class StreamingInsertsResults {
+    private final ConcurrentLinkedQueue<java.time.Duration> rpcLatencies =
+        new ConcurrentLinkedQueue<>();
+    private final ConcurrentLinkedQueue<String> rpcStatus = new 
ConcurrentLinkedQueue<>();
+    // Represents <Rpc Status, Number of Rows> for rows that are retried 
because of a failed
+    // InsertAll RPC.
+    private final ConcurrentLinkedQueue<KV<String, Integer>> 
retriedRowsByStatus =
+        new ConcurrentLinkedQueue<>();
+    private final AtomicInteger successfulRowsCount = new AtomicInteger();
+    private final AtomicInteger failedRowsCount = new AtomicInteger();
+    private final AtomicBoolean isWritable = new AtomicBoolean(true);

Review Comment:
   close!
   
   for AutoValue magic these will need to be defined as abstract getters() like:
   
   ```
   abstract static class StreamingInsertsResults {
       abstract ConcurrentLinkedQueue<java.time.Duration> rpcLatencies();
       abstract  ConcurrentLinkedQueue<String> rpcStatus();
       .....etc.
   }
   ```
   
   then you can expose whatever in you static create method and pass the 
default values of the members to `new 
AutoValue_BigQuerySinkMetric_StreamingInsertsResults(new 
ConcurrentLinkedQueue<>() .....);
   
   rest looks good



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

To unsubscribe, e-mail: [email protected]

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

Reply via email to