|
36 | 36 | import org.apache.beam.runners.core.metrics.DistributionData;
|
37 | 37 | import org.apache.beam.runners.core.metrics.GaugeCell;
|
38 | 38 | import org.apache.beam.runners.core.metrics.MetricsMap;
|
| 39 | +import org.apache.beam.runners.core.metrics.MonitoringInfoConstants; |
39 | 40 | import org.apache.beam.runners.core.metrics.StringSetCell;
|
40 | 41 | import org.apache.beam.runners.core.metrics.StringSetData;
|
41 | 42 | import org.apache.beam.sdk.metrics.BoundedTrie;
|
@@ -240,10 +241,15 @@ private FluentIterable<CounterUpdate> gaugeUpdates() {
|
240 | 241 | @Override
|
241 | 242 | public @Nullable CounterUpdate apply(
|
242 | 243 | @Nonnull Map.Entry<MetricName, GaugeCell> entry) {
|
243 |
| - long value = entry.getValue().getCumulative().value(); |
244 |
| - org.joda.time.Instant timestamp = entry.getValue().getCumulative().timestamp(); |
245 |
| - return MetricsToCounterUpdateConverter.fromGauge( |
246 |
| - MetricKey.create(stepName, entry.getKey()), value, timestamp); |
| 244 | + if (!MonitoringInfoConstants.isPerWorkerMetric(entry.getKey())) { |
| 245 | + long value = entry.getValue().getCumulative().value(); |
| 246 | + org.joda.time.Instant timestamp = entry.getValue().getCumulative().timestamp(); |
| 247 | + return MetricsToCounterUpdateConverter.fromGauge( |
| 248 | + MetricKey.create(stepName, entry.getKey()), value, timestamp); |
| 249 | + } else { |
| 250 | + // add a test for this. |
| 251 | + return null; |
| 252 | + } |
247 | 253 | }
|
248 | 254 | })
|
249 | 255 | .filter(Predicates.notNull());
|
@@ -389,9 +395,10 @@ Iterable<PerStepNamespaceMetrics> extractPerWorkerMetricUpdates() {
|
389 | 395 |
|
390 | 396 | gauges.forEach(
|
391 | 397 | (k, v) -> {
|
392 |
| - // Check if metric name has the per worker label set |
393 |
| - if (k.getLabels().containsKey("PER_WORKER_METRIC") |
394 |
| - && k.getLabels().get("PER_WORKER_METRIC").equals("true")) { |
| 398 | + // Check if metric name has the per worker label set. |
| 399 | + // TODO(Naireen): Populate local map with perWorkerMetrics so we don't need to check each |
| 400 | + // time we update the metrics. |
| 401 | + if (MonitoringInfoConstants.isPerWorkerMetric(k)) { |
395 | 402 | Long val = v.getCumulative().value();
|
396 | 403 | per_worker_gauges.put(k, val);
|
397 | 404 | v.reset();
|
|
0 commit comments