[
https://issues.apache.org/jira/browse/BEAM-4775?focusedWorklogId=209281&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-209281
]
ASF GitHub Bot logged work on BEAM-4775:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Mar/19 01:34
Start Date: 07/Mar/19 01:34
Worklog Time Spent: 10m
Work Description: ajamato commented on pull request #7934: [BEAM-4775]
add GetJobMetrics RPC
URL: https://github.com/apache/beam/pull/7934#discussion_r263205226
##########
File path:
runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MetricUpdatesProtos.java
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.runners.core.metrics;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.BiConsumer;
+import org.apache.beam.model.pipeline.v1.MetricsApi.MonitoringInfo;
+import org.apache.beam.sdk.metrics.MetricKey;
+
+/** Convert {@link MetricUpdates} to a {@link List} of {@link MonitoringInfo}.
*/
+public class MetricUpdatesProtos {
+ public static List<MonitoringInfo> toProto(MetricUpdates metricUpdates) {
+ ArrayList<MonitoringInfo> monitoringInfos = new ArrayList<>();
+
+ fromMetrics(
Review comment:
Similarily in this code, the BiConsumer usage complicates this and makes it
harder to read.
Its simple enough to
(1) make a for loop for each of these calls, iterating through the
MetricUpdates
(2) call a helper to do everything else
A lot of this problem comes from the fact that MetricUpdate is just a
generic class with no knowledge of what its actually storing. So you can't take
advantage of any polymophism with a MetricGaugeUpdate,
MetricDistributionUpdate, MetricCounterUpdate, etc. So a lot of the code
surrounding this special cases or writes switches for each one. If this
polymorphism existed you could tell the MetricUpdate to set itself on a
MonitoringInfo/SimpleMonitoringInfoBuilder. That's an option as well, but it
will require a larger change. Better to table for now.
A lot of the cases where you pass in a callback seem to be for similar
reasons.
----------------------------------------------------------------
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: 209281)
Time Spent: 34h 20m (was: 34h 10m)
> JobService should support returning metrics
> -------------------------------------------
>
> Key: BEAM-4775
> URL: https://issues.apache.org/jira/browse/BEAM-4775
> Project: Beam
> Issue Type: Bug
> Components: beam-model
> Reporter: Eugene Kirpichov
> Assignee: Ryan Williams
> Priority: Major
> Labels: triaged
> Time Spent: 34h 20m
> Remaining Estimate: 0h
>
> Design doc: [https://s.apache.org/get-metrics-api].
> h1. Relevant PRs in flight:
> h2. Approved / Ready to merge:
> None atm.
> h2. Ready for Review:
> * [#7971|https://github.com/apache/beam/pull/7971]: Flink portable metrics:
> get ptransform from MonitoringInfo, not stage name
> ** this is a simpler, Flink-specific PR that is basically duplicated inside
> each of the following two, so may be worth trying to merge in first
> * [#7934|https://github.com/apache/beam/pull/7934]: add GetJobMetrics RPC,
> Java+Python SDK support for it
> * #[7915|https://github.com/apache/beam/pull/7915]: use MonitoringInfo data
> model in Java SDK metrics
> h2. Iterating / Discussing:
> * [#7868|https://github.com/apache/beam/pull/7868]: MonitoringInfo URN tweaks
> h2. Merged
> * [#7867|https://github.com/apache/beam/pull/7867]: key MetricResult by a
> MetricKey
> * [#7938|https://github.com/apache/beam/pull/7938]: move MonitoringInfo
> protos to model/pipeline module
> * [#7883|https://github.com/apache/beam/pull/7883]: Add
> MetricQueryResults.allMetrics() helper
> * [#7866|https://github.com/apache/beam/pull/7866]: move function helpers
> from fn-harness to sdks/java/core
> * [#7890|https://github.com/apache/beam/pull/7890]: consolidate MetricResult
> implementations
> h2. Closed
> * [#7876|https://github.com/apache/beam/pull/7876]: Clean up metric protos;
> support integer distributions, gauges
> h1. Likely pieces still to come:
> Per recent discussion with [~robertwb], I'm going to move the MonitoringInfo
> protos into the {{model/pipeline}} module, which the Job API, Fn API, and
> sdks/java/core all depend on already, as it's a good/central place for them.
> h1. Previous Description:
> [https://github.com/apache/beam/blob/master/model/job-management/src/main/proto/beam_job_api.proto]
> currently doesn't appear to have a way for JobService to return metrics to a
> user, even though
> [https://github.com/apache/beam/blob/master/model/fn-execution/src/main/proto/beam_fn_api.proto]
> includes support for reporting SDK metrics to the runner harness.
> Metrics are apparently necessary to run any ValidatesRunner tests because
> PAssert needs to validate that the assertions succeeded. However, this
> statement should be double-checked: perhaps it's possible to somehow work
> with PAssert without metrics support.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)