You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "JayajP (via GitHub)" <gi...@apache.org> on 2024/02/14 21:39:33 UTC
[PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
JayajP opened a new pull request, #30320:
URL: https://github.com/apache/beam/pull/30320
**Please** add a meaningful description for your change here
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on PR #30320:
URL: https://github.com/apache/beam/pull/30320#issuecomment-1946863986
R: @m-trieu
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #30320:
URL: https://github.com/apache/beam/pull/30320#discussion_r1491496610
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImpl.java:
##########
@@ -1258,6 +1278,10 @@ <T> long insertAll(
}
}
}
+ streamingInsertsResults.failedRowsCount.getAndAdd(allErrors.size());
Review Comment:
see comment about making instance method
maybe this one could be something like:
```
@AutoValue
public abstract static StreamingInsertResults {
...
void updateRowCount(int failedRowCount, int successRowCount) {
failedRowsCount().getAndAdd(failedRowCount);
successfulRowsCount().set(successRowCount - failedRowsCount.get())
}
...
}
```
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +337,83 @@ public static void reportFailedRPCMetrics(
updateRpcLatencyMetric(c, method);
}
+ /**
+ * Results of a batch of InsertAll RPCs. Used to update metrics with the {@code
+ * updateStreamingInsertsMetrics} method. Member variables should be thread-safe.
+ */
+ public static class StreamingInsertsResults {
Review Comment:
if this is a data class, can you use AutoValue?
https://g3doc.corp.google.com/third_party/java_src/auto/value/g3doc/index.md?cl=head
can also annotate with `@ThreadSafe`
also the members are threadsafe individually, but if you need atomic operations across multiple members that will still require a lock (`synchronized (someObject)`)
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +337,83 @@ public static void reportFailedRPCMetrics(
updateRpcLatencyMetric(c, method);
}
+ /**
+ * Results of a batch of InsertAll RPCs. Used to update metrics with the {@code
+ * updateStreamingInsertsMetrics} method. Member variables should be thread-safe.
+ */
+ public static class StreamingInsertsResults {
+ final ConcurrentLinkedQueue<java.time.Duration> rpcLatencies = new ConcurrentLinkedQueue<>();
+ final ConcurrentLinkedQueue<String> rpcStatus = new ConcurrentLinkedQueue<>();
+ // Represents <Rpc Status, Number of Rows> for rows that are retried because the InsertAll RPC
+ // failed.
+ final ConcurrentLinkedQueue<KV<String, Integer>> retriedRowsByStatus =
+ new ConcurrentLinkedQueue<>();
+ final AtomicInteger successfulRowsCount = new AtomicInteger();
+ final AtomicInteger failedRowsCount = new AtomicInteger();
+ // Rows that were retried due to an internal BigQuery Error even though the InsertAll RPC
+ // succeeded.
+ final AtomicInteger internalRetriedRowsCount = new AtomicInteger();
+ }
+
+ /**
+ * Update the {@code RpcRequestsCount}, {@code RpcLatency}, and {@code RowsAppendedCount} metrics
+ * based on the results of StreamingInserts RPC calls.
+ *
+ * @param results Result of StreamingInsert RPC calls
+ * @param tableRef BigQuery table that was written to.
+ */
Review Comment:
how about making this an instance method w/in `StreamingInsertsResults`?
can be like
```
public void updateMetrics(@Nullable TableReference tableRef) {
...//do operations on members instead of passed in StreamingInsertsResults.
}
```
this can be done even with AutoValue
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +337,83 @@ public static void reportFailedRPCMetrics(
updateRpcLatencyMetric(c, method);
}
+ /**
+ * Results of a batch of InsertAll RPCs. Used to update metrics with the {@code
+ * updateStreamingInsertsMetrics} method. Member variables should be thread-safe.
+ */
+ public static class StreamingInsertsResults {
+ final ConcurrentLinkedQueue<java.time.Duration> rpcLatencies = new ConcurrentLinkedQueue<>();
+ final ConcurrentLinkedQueue<String> rpcStatus = new ConcurrentLinkedQueue<>();
+ // Represents <Rpc Status, Number of Rows> for rows that are retried because the InsertAll RPC
+ // failed.
+ final ConcurrentLinkedQueue<KV<String, Integer>> retriedRowsByStatus =
+ new ConcurrentLinkedQueue<>();
+ final AtomicInteger successfulRowsCount = new AtomicInteger();
+ final AtomicInteger failedRowsCount = new AtomicInteger();
+ // Rows that were retried due to an internal BigQuery Error even though the InsertAll RPC
+ // succeeded.
+ final AtomicInteger internalRetriedRowsCount = new AtomicInteger();
+ }
+
+ /**
+ * Update the {@code RpcRequestsCount}, {@code RpcLatency}, and {@code RowsAppendedCount} metrics
+ * based on the results of StreamingInserts RPC calls.
+ *
+ * @param results Result of StreamingInsert RPC calls
+ * @param tableRef BigQuery table that was written to.
+ */
+ public static void updateStreamingInsertsMetrics(
Review Comment:
when would the inputs be null?
mark results and tableRef as `@Nullable` like
`(@Nullable StreamingInsertsResults results, @Nullable TableReference tableRef)`
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +337,83 @@ public static void reportFailedRPCMetrics(
updateRpcLatencyMetric(c, method);
}
+ /**
+ * Results of a batch of InsertAll RPCs. Used to update metrics with the {@code
+ * updateStreamingInsertsMetrics} method. Member variables should be thread-safe.
+ */
+ public static class StreamingInsertsResults {
+ final ConcurrentLinkedQueue<java.time.Duration> rpcLatencies = new ConcurrentLinkedQueue<>();
+ final ConcurrentLinkedQueue<String> rpcStatus = new ConcurrentLinkedQueue<>();
+ // Represents <Rpc Status, Number of Rows> for rows that are retried because the InsertAll RPC
+ // failed.
+ final ConcurrentLinkedQueue<KV<String, Integer>> retriedRowsByStatus =
+ new ConcurrentLinkedQueue<>();
+ final AtomicInteger successfulRowsCount = new AtomicInteger();
+ final AtomicInteger failedRowsCount = new AtomicInteger();
+ // Rows that were retried due to an internal BigQuery Error even though the InsertAll RPC
+ // succeeded.
+ final AtomicInteger internalRetriedRowsCount = new AtomicInteger();
+ }
+
+ /**
+ * Update the {@code RpcRequestsCount}, {@code RpcLatency}, and {@code RowsAppendedCount} metrics
+ * based on the results of StreamingInserts RPC calls.
+ *
+ * @param results Result of StreamingInsert RPC calls
+ * @param tableRef BigQuery table that was written to.
+ */
+ public static void updateStreamingInsertsMetrics(
+ StreamingInsertsResults results, TableReference tableRef) {
+ if (results == null || tableRef == null) {
+ return;
+ }
+
+ String shortTableId =
+ String.format("datasets/%s/tables/%s", tableRef.getDatasetId(), tableRef.getTableId());
+ Map<String, Integer> rpcRequetsRpcStatusMap = new HashMap<>();
Review Comment:
see comment above about atomicity for the concurrent collections.
They allow concurrent writes to the data structure (i.e you could be iterating/reading here, while updates are happening to the data structure without ConcurrentModificationException, it doesn't guarantee that you will see every update while iterating -`Iterators are weakly consistent, returning elements reflecting the state of the queue at some point at or since the creation of the iterator. They do not throw [ConcurrentModificationException](https://docs.oracle.com/javase%2F7%2Fdocs%2Fapi%2F%2F/java/util/ConcurrentModificationException.html), and may proceed concurrently with other operations. Elements contained in the queue since the creation of the iterator will be returned exactly once.` from javadoc)
if you want (not sure if you do), to tie the operations together (the iterating over `results.rpcStatus` and `results.retriedRowsByStatus`) you will need to wrap the iteration in a lock like :
```
synchronized (someObject) // if instance method in StreamingInsertsResults, can use synchronized(this)
for (String status : results.rpcStatus) {
Integer currentVal = rpcRequetsRpcStatusMap.getOrDefault(status, 0);
rpcRequetsRpcStatusMap.put(status, currentVal + 1);
}
for (KV<String, Integer> retryCountByStatus : results.retriedRowsByStatus) {
Integer currentVal = retriedRowsRpcStatusMap.getOrDefault(retryCountByStatus.getKey(), 0);
retriedRowsRpcStatusMap.put(
retryCountByStatus.getKey(), currentVal + retryCountByStatus.getValue());
}
}
```
depending on the behavior you want, if you don't need to tie these 2 operations together than its ok to leave as is.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on code in PR #30320:
URL: https://github.com/apache/beam/pull/30320#discussion_r1493043486
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +337,83 @@ public static void reportFailedRPCMetrics(
updateRpcLatencyMetric(c, method);
}
+ /**
+ * Results of a batch of InsertAll RPCs. Used to update metrics with the {@code
+ * updateStreamingInsertsMetrics} method. Member variables should be thread-safe.
+ */
+ public static class StreamingInsertsResults {
+ final ConcurrentLinkedQueue<java.time.Duration> rpcLatencies = new ConcurrentLinkedQueue<>();
+ final ConcurrentLinkedQueue<String> rpcStatus = new ConcurrentLinkedQueue<>();
+ // Represents <Rpc Status, Number of Rows> for rows that are retried because the InsertAll RPC
+ // failed.
+ final ConcurrentLinkedQueue<KV<String, Integer>> retriedRowsByStatus =
+ new ConcurrentLinkedQueue<>();
+ final AtomicInteger successfulRowsCount = new AtomicInteger();
+ final AtomicInteger failedRowsCount = new AtomicInteger();
+ // Rows that were retried due to an internal BigQuery Error even though the InsertAll RPC
+ // succeeded.
+ final AtomicInteger internalRetriedRowsCount = new AtomicInteger();
+ }
+
+ /**
+ * Update the {@code RpcRequestsCount}, {@code RpcLatency}, and {@code RowsAppendedCount} metrics
+ * based on the results of StreamingInserts RPC calls.
+ *
+ * @param results Result of StreamingInsert RPC calls
+ * @param tableRef BigQuery table that was written to.
+ */
+ public static void updateStreamingInsertsMetrics(
Review Comment:
They should not be null, but BigQueryServicesImpl is wrapped around a `SuppressWarnings nullness` so I was still able to pass a null input for this function. Added the annotation.
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +337,83 @@ public static void reportFailedRPCMetrics(
updateRpcLatencyMetric(c, method);
}
+ /**
+ * Results of a batch of InsertAll RPCs. Used to update metrics with the {@code
+ * updateStreamingInsertsMetrics} method. Member variables should be thread-safe.
+ */
+ public static class StreamingInsertsResults {
+ final ConcurrentLinkedQueue<java.time.Duration> rpcLatencies = new ConcurrentLinkedQueue<>();
+ final ConcurrentLinkedQueue<String> rpcStatus = new ConcurrentLinkedQueue<>();
+ // Represents <Rpc Status, Number of Rows> for rows that are retried because the InsertAll RPC
+ // failed.
+ final ConcurrentLinkedQueue<KV<String, Integer>> retriedRowsByStatus =
+ new ConcurrentLinkedQueue<>();
+ final AtomicInteger successfulRowsCount = new AtomicInteger();
+ final AtomicInteger failedRowsCount = new AtomicInteger();
+ // Rows that were retried due to an internal BigQuery Error even though the InsertAll RPC
+ // succeeded.
+ final AtomicInteger internalRetriedRowsCount = new AtomicInteger();
+ }
+
+ /**
+ * Update the {@code RpcRequestsCount}, {@code RpcLatency}, and {@code RowsAppendedCount} metrics
+ * based on the results of StreamingInserts RPC calls.
+ *
+ * @param results Result of StreamingInsert RPC calls
+ * @param tableRef BigQuery table that was written to.
+ */
Review Comment:
done.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on code in PR #30320:
URL: https://github.com/apache/beam/pull/30320#discussion_r1493041680
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +337,83 @@ public static void reportFailedRPCMetrics(
updateRpcLatencyMetric(c, method);
}
+ /**
+ * Results of a batch of InsertAll RPCs. Used to update metrics with the {@code
+ * updateStreamingInsertsMetrics} method. Member variables should be thread-safe.
+ */
+ public static class StreamingInsertsResults {
Review Comment:
Added a more nuanced comment about the thread safety guarantees of this class.
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImpl.java:
##########
@@ -1258,6 +1278,10 @@ <T> long insertAll(
}
}
}
+ streamingInsertsResults.failedRowsCount.getAndAdd(allErrors.size());
Review Comment:
Done.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #30320:
URL: https://github.com/apache/beam/pull/30320#discussion_r1491496488
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +337,83 @@ public static void reportFailedRPCMetrics(
updateRpcLatencyMetric(c, method);
}
+ /**
+ * Results of a batch of InsertAll RPCs. Used to update metrics with the {@code
+ * updateStreamingInsertsMetrics} method. Member variables should be thread-safe.
+ */
+ public static class StreamingInsertsResults {
Review Comment:
if this is a data class, can you use AutoValue?
https://g3doc.corp.google.com/third_party/java_src/auto/value/g3doc/index.md?cl=head
can also annotate with `@ThreadSafe` instead of commenting
also the members are threadsafe individually, but if you need atomic operations across multiple members that will still require a lock (`synchronized (someObject)`)
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #30320:
URL: https://github.com/apache/beam/pull/30320#issuecomment-1946868775
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on code in PR #30320:
URL: https://github.com/apache/beam/pull/30320#discussion_r1493041376
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +337,83 @@ public static void reportFailedRPCMetrics(
updateRpcLatencyMetric(c, method);
}
+ /**
+ * Results of a batch of InsertAll RPCs. Used to update metrics with the {@code
+ * updateStreamingInsertsMetrics} method. Member variables should be thread-safe.
+ */
+ public static class StreamingInsertsResults {
+ final ConcurrentLinkedQueue<java.time.Duration> rpcLatencies = new ConcurrentLinkedQueue<>();
+ final ConcurrentLinkedQueue<String> rpcStatus = new ConcurrentLinkedQueue<>();
+ // Represents <Rpc Status, Number of Rows> for rows that are retried because the InsertAll RPC
+ // failed.
+ final ConcurrentLinkedQueue<KV<String, Integer>> retriedRowsByStatus =
+ new ConcurrentLinkedQueue<>();
+ final AtomicInteger successfulRowsCount = new AtomicInteger();
+ final AtomicInteger failedRowsCount = new AtomicInteger();
+ // Rows that were retried due to an internal BigQuery Error even though the InsertAll RPC
+ // succeeded.
+ final AtomicInteger internalRetriedRowsCount = new AtomicInteger();
+ }
+
+ /**
+ * Update the {@code RpcRequestsCount}, {@code RpcLatency}, and {@code RowsAppendedCount} metrics
+ * based on the results of StreamingInserts RPC calls.
+ *
+ * @param results Result of StreamingInsert RPC calls
+ * @param tableRef BigQuery table that was written to.
+ */
+ public static void updateStreamingInsertsMetrics(
+ StreamingInsertsResults results, TableReference tableRef) {
+ if (results == null || tableRef == null) {
+ return;
+ }
+
+ String shortTableId =
+ String.format("datasets/%s/tables/%s", tableRef.getDatasetId(), tableRef.getTableId());
+ Map<String, Integer> rpcRequetsRpcStatusMap = new HashMap<>();
Review Comment:
Don't need synchronization across member variables
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "m-trieu (via GitHub)" <gi...@apache.org>.
m-trieu commented on code in PR #30320:
URL: https://github.com/apache/beam/pull/30320#discussion_r1500091697
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQuerySinkMetrics.java:
##########
@@ -326,6 +337,83 @@ public static void reportFailedRPCMetrics(
updateRpcLatencyMetric(c, method);
}
+ /**
+ * Results of a batch of InsertAll RPCs. Used to update metrics with the {@code
+ * updateStreamingInsertsMetrics} method. Member variables should be thread-safe.
+ */
+ public static class StreamingInsertsResults {
+ final ConcurrentLinkedQueue<java.time.Duration> rpcLatencies = new ConcurrentLinkedQueue<>();
+ final ConcurrentLinkedQueue<String> rpcStatus = new ConcurrentLinkedQueue<>();
+ // Represents <Rpc Status, Number of Rows> for rows that are retried because the InsertAll RPC
+ // failed.
+ final ConcurrentLinkedQueue<KV<String, Integer>> retriedRowsByStatus =
+ new ConcurrentLinkedQueue<>();
+ final AtomicInteger successfulRowsCount = new AtomicInteger();
+ final AtomicInteger failedRowsCount = new AtomicInteger();
+ // Rows that were retried due to an internal BigQuery Error even though the InsertAll RPC
+ // succeeded.
+ final AtomicInteger internalRetriedRowsCount = new AtomicInteger();
+ }
+
+ /**
+ * Update the {@code RpcRequestsCount}, {@code RpcLatency}, and {@code RowsAppendedCount} metrics
+ * based on the results of StreamingInserts RPC calls.
+ *
+ * @param results Result of StreamingInsert RPC calls
+ * @param tableRef BigQuery table that was written to.
+ */
+ public static void updateStreamingInsertsMetrics(
Review Comment:
ah gotcha thats unfortunate sgtm
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn merged PR #30320:
URL: https://github.com/apache/beam/pull/30320
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Update BigQuerySinkMetrics for StreamingInserts. [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on PR #30320:
URL: https://github.com/apache/beam/pull/30320#issuecomment-1949429099
Thanks for the review Martin, switched `StreamingInsertsResults` to an AutoValue class, made the instance-variables private and added some update methods to update the instance-variables.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org