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 2023/10/20 20:21:49 UTC
[PR] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
JayajP opened a new pull request, #29098:
URL: https://github.com/apache/beam/pull/29098
Implement the following set of metrics in BigQuery's StorageWriteAPI transforms. These metrics will be stored in the PerWorkerMetrics container defined in (#28923)
1. `AppendRowsRowStatus` Counter
Metric that tracks the status of BigQuery rows after making an AppendRows RPC call.
- If the AppendRows RPC succeeds, it tracks the number of rows that been successfully scheduled for a flush.
- If the AppendRows RPC fails, it tracks the number of rows that will be retried and failed.
Metric has labels the following labels:
- `RowStatus`: Status of the BigQuery rows after , one of `SUCCESSFUL`, `RETRIED`, `FAILED`
- `Status`: gRPC status of the AppendRows RPC
- `TableId`: 'datasets/{ }/tables/{ }' that the rows are sent to.
2. `ThrottledTime` Counter
Tracks the total time spent waiting between RPC retries.
Metric has labels the following labels:
- `Method`: BigQuery method that's causing the throttle. One of `AppendRows`, `FlushRows`, `FinalizeStream`.
3. `RpcRequests` Counter
Tracks the Rpc Status of various BigQuery write methods.
Metric has labels the following labels:
- `Method`: BigQuery sink method. One of `AppendRows`, `FlushRows`, `FinalizeStream`.
- `Status`: gRPC status of the AppendRows RPC
- `TableId`: 'datasets/{ }/tables/{ }' that the rows are sent to.
4. `RpcLatency` Histogram:
Tracks the Rpc Latency of various BigQuery write methods.
Metric has labels the following labels:
- `Method`: BigQuery sink method. One of `AppendRows`, `FlushRows`, `FinalizeStream`.
------------------------
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on code in PR #29098:
URL: https://github.com/apache/beam/pull/29098#discussion_r1387063377
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StorageApiFlushAndFinalizeDoFn.java:
##########
@@ -181,6 +193,13 @@ public void process(PipelineOptions pipelineOptions, @Element KV<String, Operati
},
// onSuccess
c -> {
+ BigQuerySinkMetrics.FlushRowsCounter("ok").inc();
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on code in PR #29098:
URL: https://github.com/apache/beam/pull/29098#discussion_r1387063059
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/DelegatingPerWorkerHistogram.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.metrics;
+
+import java.io.Serializable;
+import org.apache.beam.sdk.annotations.Internal;
+import org.apache.beam.sdk.util.HistogramData;
+
+/** Implementation of {@link Histogram} that delegates to the instance for the current context. */
+@Internal
+public class DelegatingPerWorkerHistogram implements Metric, Histogram, Serializable {
+ private final MetricName name;
+ private final HistogramData.BucketType bucketType;
+ private final boolean processWideContainer;
+
+ public DelegatingPerWorkerHistogram(
+ MetricName name, HistogramData.BucketType bucketType, boolean processWideContainer) {
+ this.name = name;
+ this.bucketType = bucketType;
+ this.processWideContainer = processWideContainer;
+ }
+
+ public DelegatingPerWorkerHistogram(MetricName name, HistogramData.BucketType bucketType) {
+ this(name, bucketType, false);
+ }
+
+ @Override
+ public void update(double value) {
+ MetricsContainer container =
+ processWideContainer
+ ? MetricsEnvironment.getProcessWideContainer()
+ : MetricsEnvironment.getCurrentContainer();
+ if (container != null) {
+ container.getPerWorkerHistogram(name, bucketType).update(value);
Review Comment:
Extended DelegatingHistogram to also handle perWorkerHistogram
--
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on code in PR #29098:
URL: https://github.com/apache/beam/pull/29098#discussion_r1387078339
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StorageApiWriteUnshardedRecords.java:
##########
@@ -643,11 +650,20 @@ long flush(
contexts -> {
AppendRowsContext failedContext =
Preconditions.checkStateNotNull(Iterables.getFirst(contexts, null));
+ Instant operationEndTime = Instant.now();
Review Comment:
Repacked updating the `RpcRequests` and `RpcLatency` metrics into utility methods since that are reused across all write methods. These updates are now handled by `reportSuccessfulRpcMetrics` and `reportFailedRPCMetrics`.
It's not straightforward to refactor updates `AppendRowsRowStatus` into a utility. When we update this metric we need to know the number of rows that were failed/retried/succeeded so it's more embedded in the code.
--
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on code in PR #29098:
URL: https://github.com/apache/beam/pull/29098#discussion_r1387062743
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/DelegatingPerWorkerCounter.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.metrics;
+
+import java.io.Serializable;
+import org.apache.beam.sdk.annotations.Internal;
+
+/** Implementation of {@link Counter} that delegates to the instance for the current context. */
+@Internal
+public class DelegatingPerWorkerCounter implements Metric, Counter, Serializable {
+ private final MetricName name;
+ private final boolean processWideContainer;
+
+ public DelegatingPerWorkerCounter(MetricName name) {
+ this(name, false);
+ }
+
+ public DelegatingPerWorkerCounter(MetricName name, boolean processWideContainer) {
+ this.name = name;
+ this.processWideContainer = processWideContainer;
+ }
+
+ /** Increment the counter. */
+ @Override
+ public void inc() {
+ inc(1);
+ }
+
+ /** Increment the counter by the given amount. */
+ @Override
+ public void inc(long n) {
+ MetricsContainer container =
+ this.processWideContainer
+ ? MetricsEnvironment.getProcessWideContainer()
+ : MetricsEnvironment.getCurrentContainer();
+ if (container != null) {
+ container.getPerWorkerCounter(name).inc(n);
Review Comment:
Extended DelegatingCounter to also handle perWorkerCounters.
--
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "johnjcasey (via GitHub)" <gi...@apache.org>.
johnjcasey commented on code in PR #29098:
URL: https://github.com/apache/beam/pull/29098#discussion_r1370294823
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StorageApiFlushAndFinalizeDoFn.java:
##########
@@ -181,6 +193,13 @@ public void process(PipelineOptions pipelineOptions, @Element KV<String, Operati
},
// onSuccess
c -> {
+ BigQuerySinkMetrics.FlushRowsCounter("ok").inc();
Review Comment:
I'd prefer to not have a magic string here
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StorageApiFinalizeWritesDoFn.java:
##########
@@ -126,6 +140,12 @@ public void process(PipelineOptions pipelineOptions, @Element KV<String, String>
rowsFinalized.inc(response.getRowCount());
finalizeOperationsSucceeded.inc();
+ BigQuerySinkMetrics.FinalizeStreamCounter("ok").inc();
+ @Nullable Instant operationStartTime = c.getOperationStartTime();
+ Instant operationEndTime = Instant.now();
+ BigQuerySinkMetrics.UpdateRpcLatencyMetric(
Review Comment:
Is updating the metric here accurate for failed operations?
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/DelegatingPerWorkerCounter.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.metrics;
+
+import java.io.Serializable;
+import org.apache.beam.sdk.annotations.Internal;
+
+/** Implementation of {@link Counter} that delegates to the instance for the current context. */
+@Internal
+public class DelegatingPerWorkerCounter implements Metric, Counter, Serializable {
+ private final MetricName name;
+ private final boolean processWideContainer;
+
+ public DelegatingPerWorkerCounter(MetricName name) {
+ this(name, false);
+ }
+
+ public DelegatingPerWorkerCounter(MetricName name, boolean processWideContainer) {
+ this.name = name;
+ this.processWideContainer = processWideContainer;
+ }
+
+ /** Increment the counter. */
+ @Override
+ public void inc() {
+ inc(1);
+ }
+
+ /** Increment the counter by the given amount. */
+ @Override
+ public void inc(long n) {
+ MetricsContainer container =
+ this.processWideContainer
+ ? MetricsEnvironment.getProcessWideContainer()
+ : MetricsEnvironment.getCurrentContainer();
+ if (container != null) {
+ container.getPerWorkerCounter(name).inc(n);
Review Comment:
Do we need a separate implementation of Delegating counter just for this line change?
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/DelegatingPerWorkerHistogram.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.metrics;
+
+import java.io.Serializable;
+import org.apache.beam.sdk.annotations.Internal;
+import org.apache.beam.sdk.util.HistogramData;
+
+/** Implementation of {@link Histogram} that delegates to the instance for the current context. */
+@Internal
+public class DelegatingPerWorkerHistogram implements Metric, Histogram, Serializable {
+ private final MetricName name;
+ private final HistogramData.BucketType bucketType;
+ private final boolean processWideContainer;
+
+ public DelegatingPerWorkerHistogram(
+ MetricName name, HistogramData.BucketType bucketType, boolean processWideContainer) {
+ this.name = name;
+ this.bucketType = bucketType;
+ this.processWideContainer = processWideContainer;
+ }
+
+ public DelegatingPerWorkerHistogram(MetricName name, HistogramData.BucketType bucketType) {
+ this(name, bucketType, false);
+ }
+
+ @Override
+ public void update(double value) {
+ MetricsContainer container =
+ processWideContainer
+ ? MetricsEnvironment.getProcessWideContainer()
+ : MetricsEnvironment.getCurrentContainer();
+ if (container != null) {
+ container.getPerWorkerHistogram(name, bucketType).update(value);
Review Comment:
same idea here
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StorageApiWriteUnshardedRecords.java:
##########
@@ -643,11 +650,20 @@ long flush(
contexts -> {
AppendRowsContext failedContext =
Preconditions.checkStateNotNull(Iterables.getFirst(contexts, null));
+ Instant operationEndTime = Instant.now();
Review Comment:
We have this pattern all over the place, of grabbing the start time, updating a metric, grabbing error code, etc.
Is it possible to repackage this into a reusable utility method for clarity?
--
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "johnjcasey (via GitHub)" <gi...@apache.org>.
johnjcasey commented on PR #29098:
URL: https://github.com/apache/beam/pull/29098#issuecomment-1813092309
That test failure is a flake, this is good to go!
--
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "johnjcasey (via GitHub)" <gi...@apache.org>.
johnjcasey commented on PR #29098:
URL: https://github.com/apache/beam/pull/29098#issuecomment-1804328267
This LGTM. I'm rerunning the tests before merge however.
--
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on PR #29098:
URL: https://github.com/apache/beam/pull/29098#issuecomment-1813097623
There's a single jenkins test failure but the corresponding Github actions for that test passes.
--
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "johnjcasey (via GitHub)" <gi...@apache.org>.
johnjcasey commented on PR #29098:
URL: https://github.com/apache/beam/pull/29098#issuecomment-1812636831
Retest this please
--
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "johnjcasey (via GitHub)" <gi...@apache.org>.
johnjcasey merged PR #29098:
URL: https://github.com/apache/beam/pull/29098
--
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #29098:
URL: https://github.com/apache/beam/pull/29098#issuecomment-1773586183
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`
--
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] Implement a handful of perworkermetrics the bigquery sink (#28903). [beam]
Posted by "JayajP (via GitHub)" <gi...@apache.org>.
JayajP commented on code in PR #29098:
URL: https://github.com/apache/beam/pull/29098#discussion_r1387065406
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StorageApiFinalizeWritesDoFn.java:
##########
@@ -126,6 +140,12 @@ public void process(PipelineOptions pipelineOptions, @Element KV<String, String>
rowsFinalized.inc(response.getRowCount());
finalizeOperationsSucceeded.inc();
+ BigQuerySinkMetrics.FinalizeStreamCounter("ok").inc();
+ @Nullable Instant operationStartTime = c.getOperationStartTime();
+ Instant operationEndTime = Instant.now();
+ BigQuerySinkMetrics.UpdateRpcLatencyMetric(
Review Comment:
This is clearer with the new method to update RpcRequests and RpcLatency metrics.
--
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