[ 
https://issues.apache.org/jira/browse/BEAM-10890?focusedWorklogId=489680&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-489680
 ]

ASF GitHub Bot logged work on BEAM-10890:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Sep/20 16:48
            Start Date: 23/Sep/20 16:48
    Worklog Time Spent: 10m 
      Work Description: ajamato commented on a change in pull request #12852:
URL: https://github.com/apache/beam/pull/12852#discussion_r493738743



##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StreamingWriteFn.java
##########
@@ -150,24 +143,42 @@ public void finishBundle(FinishBundleContext context) 
throws Exception {
     for (ValueInSingleWindow<ErrorT> row : failedInserts) {
       context.output(failedOutputTag, row.getValue(), row.getTimestamp(), 
row.getWindow());
     }
-
-    long currentTimeMillis = System.currentTimeMillis();
-    if (histogram.getTotalCount() > 0
-        && (currentTimeMillis - lastReportedSystemClockMillis)
-            > options.getLatencyLoggingFrequency() * 1000L) {
-      logPercentiles();
-      histogram.clear();
-      lastReportedSystemClockMillis = currentTimeMillis;
-    }
+    reportStreamingApiLogging(options);
   }
 
-  private void logPercentiles() {
-    LOG.info(
-        "Total number of streaming insert requests: {}, P99: {}ms, P90: {}ms, 
P50: {}ms",
-        histogram.getTotalCount(),
-        DoubleMath.roundToInt(histogram.p99(), RoundingMode.HALF_UP),
-        DoubleMath.roundToInt(histogram.p90(), RoundingMode.HALF_UP),
-        DoubleMath.roundToInt(histogram.p50(), RoundingMode.HALF_UP));
+  private void reportStreamingApiLogging(BigQueryOptions options) {
+    if (reportingLock.tryLock()) {
+      try {
+        long currentTimeMillis = System.currentTimeMillis();
+        if (currentTimeMillis - lastReportedSystemClockMillis
+            > options.getBqStreamingApiLoggingFrequencySec() * 1000L) {

Review comment:
       Is there a pattern here in java for this. I.e. * MILLIS_PER_SEC. Or 
converting to duration objects and comparing those?

##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StreamingWriteFn.java
##########
@@ -150,24 +143,42 @@ public void finishBundle(FinishBundleContext context) 
throws Exception {
     for (ValueInSingleWindow<ErrorT> row : failedInserts) {
       context.output(failedOutputTag, row.getValue(), row.getTimestamp(), 
row.getWindow());
     }
-
-    long currentTimeMillis = System.currentTimeMillis();
-    if (histogram.getTotalCount() > 0
-        && (currentTimeMillis - lastReportedSystemClockMillis)
-            > options.getLatencyLoggingFrequency() * 1000L) {
-      logPercentiles();
-      histogram.clear();
-      lastReportedSystemClockMillis = currentTimeMillis;
-    }
+    reportStreamingApiLogging(options);
   }
 
-  private void logPercentiles() {
-    LOG.info(
-        "Total number of streaming insert requests: {}, P99: {}ms, P90: {}ms, 
P50: {}ms",
-        histogram.getTotalCount(),
-        DoubleMath.roundToInt(histogram.p99(), RoundingMode.HALF_UP),
-        DoubleMath.roundToInt(histogram.p90(), RoundingMode.HALF_UP),
-        DoubleMath.roundToInt(histogram.p50(), RoundingMode.HALF_UP));
+  private void reportStreamingApiLogging(BigQueryOptions options) {
+    if (reportingLock.tryLock()) {
+      try {
+        long currentTimeMillis = System.currentTimeMillis();
+        if (currentTimeMillis - lastReportedSystemClockMillis
+            > options.getBqStreamingApiLoggingFrequencySec() * 1000L) {
+          StringBuilder logMessage = new StringBuilder();
+          logMessage.append(
+              String.format(
+                  "[Streaming Insert API Statistics since %s]\n",

Review comment:
       Please make this message mention BigQuery




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 489680)
    Time Spent: 1h 10m  (was: 1h)

> Log error counts to debug BigQuery streaming insert requests for Java SDK
> -------------------------------------------------------------------------
>
>                 Key: BEAM-10890
>                 URL: https://issues.apache.org/jira/browse/BEAM-10890
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-gcp
>            Reporter: Heejong Lee
>            Assignee: Heejong Lee
>            Priority: P2
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Log error counts to debug BigQuery streaming insert requests for Java SDK



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to