Repository navigation
Use MonitoringInfo data model in Java SDK metrics #7915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
20818b0
b10a2e7
31aa746
adc7872
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,9 +17,7 @@ | |
| */ | ||
| package org.apache.beam.runners.core.metrics; | ||
|
|
||
| import static java.util.Collections.singleton; | ||
| import static java.util.stream.Collectors.toList; | ||
| import static org.apache.beam.vendor.guava.v20_0.com.google.common.collect.Iterables.concat; | ||
|
|
||
| import java.io.Serializable; | ||
| import java.util.ArrayList; | ||
|
|
@@ -32,55 +30,53 @@ | |
| import org.apache.beam.sdk.metrics.MetricKey; | ||
| import org.apache.beam.sdk.metrics.MetricResult; | ||
| import org.apache.beam.sdk.metrics.MetricResults; | ||
| import org.apache.beam.sdk.metrics.labels.MetricLabels; | ||
|
|
||
| /** | ||
| * Metrics containers by step. | ||
| * | ||
| * <p>This class is not thread-safe. | ||
| */ | ||
| public class MetricsContainerStepMap implements Serializable { | ||
|
|
||
| private Map<String, MetricsContainerImpl> metricsContainers; | ||
| private MetricsContainerImpl unboundContainer = new MetricsContainerImpl(null); | ||
| private Map<MetricLabels, MetricsContainerImpl> metricsContainers; | ||
|
|
||
| public MetricsContainerStepMap() { | ||
| this.metricsContainers = new ConcurrentHashMap<>(); | ||
| } | ||
|
|
||
| /* Returns the container that is not bound to any step name. */ | ||
| public MetricsContainerImpl getUnboundContainer() { | ||
| return this.unboundContainer; | ||
| public MetricsContainerImpl ptransformContainer(String ptransform) { | ||
| return getContainer(MetricLabels.ptransform(ptransform)); | ||
| } | ||
|
|
||
| public MetricsContainerImpl pcollectionContainer(String pcollection) { | ||
| return getContainer(MetricLabels.pcollection(pcollection)); | ||
| } | ||
|
|
||
| /** Returns the container for the given step name. */ | ||
| public MetricsContainerImpl getContainer(String stepName) { | ||
| if (stepName == null) { | ||
| // TODO(BEAM-6538): Disallow this in the future, some tests rely on an empty step name today. | ||
| return getUnboundContainer(); | ||
| } | ||
| if (!metricsContainers.containsKey(stepName)) { | ||
| metricsContainers.put(stepName, new MetricsContainerImpl(stepName)); | ||
| public MetricsContainerImpl getContainer(MetricLabels labels) { | ||
| if (!metricsContainers.containsKey(labels)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesnt seem like |
||
| metricsContainers.put(labels, new MetricsContainerImpl(labels)); | ||
| } | ||
| return metricsContainers.get(stepName); | ||
| return metricsContainers.get(labels); | ||
| } | ||
|
|
||
| /** | ||
| * Update this {@link MetricsContainerStepMap} with all values from given {@link | ||
| * MetricsContainerStepMap}. | ||
| */ | ||
| public void updateAll(MetricsContainerStepMap other) { | ||
| for (Map.Entry<String, MetricsContainerImpl> container : other.metricsContainers.entrySet()) { | ||
| for (Map.Entry<MetricLabels, MetricsContainerImpl> container : | ||
| other.metricsContainers.entrySet()) { | ||
| getContainer(container.getKey()).update(container.getValue()); | ||
| } | ||
| getUnboundContainer().update(other.getUnboundContainer()); | ||
| } | ||
|
|
||
| /** | ||
| * Update {@link MetricsContainerImpl} for given step in this map with all values from given | ||
| * {@link MetricsContainerImpl}. | ||
| */ | ||
| public void update(String step, MetricsContainerImpl container) { | ||
| getContainer(step).update(container); | ||
| public void update(MetricLabels labels, MetricsContainerImpl container) { | ||
| getContainer(labels).update(container); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -172,7 +168,7 @@ public String toString() { | |
| } | ||
|
|
||
| private Iterable<MetricsContainerImpl> getMetricsContainers() { | ||
| return concat(metricsContainers.values(), singleton(unboundContainer)); | ||
| return metricsContainers.values(); | ||
| } | ||
|
|
||
| @SuppressWarnings("ConstantConditions") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come this file was fine before without importing this? : s