[
https://issues.apache.org/jira/browse/BEAM-6165?focusedWorklogId=171435&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-171435
]
ASF GitHub Bot logged work on BEAM-6165:
----------------------------------------
Author: ASF GitHub Bot
Created on: 03/Dec/18 00:40
Start Date: 03/Dec/18 00:40
Worklog Time Spent: 10m
Work Description: ryan-williams commented on a change in pull request
#7183: [BEAM-6165] send metrics to Flink in portable Flink runner
URL: https://github.com/apache/beam/pull/7183#discussion_r238123148
##########
File path:
runners/flink/src/main/java/org/apache/beam/runners/flink/metrics/FlinkMetricContainer.java
##########
@@ -77,12 +82,72 @@ public FlinkMetricContainer(RuntimeContext runtimeContext)
{
this.metricsAccumulator = (MetricsAccumulator) metricsAccumulator;
}
- MetricsContainer getMetricsContainer(String stepName) {
+ public MetricsContainer getMetricsContainer(String stepName) {
return metricsAccumulator != null
? metricsAccumulator.getLocalValue().getContainer(stepName)
: null;
}
+ /**
+ * Parse a {@link MetricName} from a {@link
+ * org.apache.beam.model.fnexecution.v1.BeamFnApi.MonitoringInfoUrns.Enum}
+ *
+ * <p>Should be consistent with {@code parse_namespace_and_name} in
monitoring_infos.py
+ *
+ * <p>TODO: not flink-specific; where should it live?
+ */
+ public static MetricName parseUrn(String urn) {
+ if (urn.startsWith(USER_COUNTER_URN_PREFIX.toString())) {
+ urn = urn.substring(USER_COUNTER_URN_PREFIX.toString().length());
+ }
+ // If it is not a user counter, just use the first part of the URN, i.e.
'beam'
+ String[] pieces = urn.split(":", 2);
+ if (pieces.length != 2) {
+ throw new IllegalArgumentException("Invalid metric URN: " + urn);
+ }
+ return MetricName.named(pieces[0], pieces[1]);
+ }
+
+ public void updateMetrics(String stepName, List<BeamFnApi.MonitoringInfo>
monitoringInfos) {
+ MetricsContainer metricsContainer = getMetricsContainer(stepName);
+ monitoringInfos.forEach(
+ monitoringInfo -> {
+ if (monitoringInfo.hasMetric()) {
+ String urn = monitoringInfo.getUrn();
+ MetricName metricName = parseUrn(urn);
+ BeamFnApi.Metric metric = monitoringInfo.getMetric();
+ if (metric.hasCounterData()) {
+ BeamFnApi.CounterData counterData = metric.getCounterData();
+ org.apache.beam.sdk.metrics.Counter counter =
metricsContainer.getCounter(metricName);
+ if (counterData.getValueCase() ==
BeamFnApi.CounterData.ValueCase.INT64_VALUE) {
+ counter.inc(counterData.getInt64Value());
+ } else {
+ throw new IllegalArgumentException("Unsupported CounterData
type: " + counterData);
+ }
+ } else if (metric.hasDistributionData()) {
+ BeamFnApi.DistributionData distributionData =
metric.getDistributionData();
+ Distribution distribution =
metricsContainer.getDistribution(metricName);
+ if (distributionData.hasIntDistributionData()) {
+ BeamFnApi.IntDistributionData intDistributionData =
+ distributionData.getIntDistributionData();
+ distribution.update(
+ intDistributionData.getSum(),
+ intDistributionData.getCount(),
+ intDistributionData.getMin(),
+ intDistributionData.getMax());
+ } else {
+ throw new IllegalArgumentException(
Review comment:
likewise, `Distribution` only supports `long`s
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: 171435)
Time Spent: 40m (was: 0.5h)
> Send metrics to Flink in portable Flink runner
> ----------------------------------------------
>
> Key: BEAM-6165
> URL: https://issues.apache.org/jira/browse/BEAM-6165
> Project: Beam
> Issue Type: Improvement
> Components: runner-flink
> Affects Versions: 2.8.0
> Reporter: Ryan Williams
> Assignee: Ryan Williams
> Priority: Major
> Labels: metrics, portability, portability-flink
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Metrics are sent from the fn harness to runnerĀ in the Python SDK (and likely
> Java soon), but the portable Flink runner doesn't pass them on to Flink,
> which it should, so that users can see them in e.g. the Flink UI or via any
> Flink metrics reporters.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)