Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import java.util.concurrent.atomic.AtomicLong;
import org.apache.beam.sdk.annotations.Experimental;
import org.apache.beam.sdk.annotations.Experimental.Kind;
import org.apache.beam.sdk.annotations.Internal;
import org.apache.beam.sdk.metrics.Counter;
import org.apache.beam.sdk.metrics.MetricName;
import org.apache.beam.sdk.metrics.MetricsContainer;

/**
* Tracks the current value (and delta) for a Counter metric for a specific context and bundle.
Expand All @@ -40,10 +42,12 @@ public class CounterCell implements Counter, MetricCell<Long> {
private final MetricName name;

/**
* Package-visibility because all {@link CounterCell CounterCells} should be created by
* {@link MetricsContainerImpl#getCounter(MetricName)}.
* Generally, runners should construct instances using the methods in
* {@link MetricsContainerImpl}, unless they need to define their own version of
* {@link MetricsContainer}. These constructors are *only* public so runners can instantiate.
*/
CounterCell(MetricName name) {
@Internal
public CounterCell(MetricName name) {
this.name = name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.concurrent.atomic.AtomicReference;
import org.apache.beam.sdk.annotations.Experimental;
import org.apache.beam.sdk.annotations.Experimental.Kind;
import org.apache.beam.sdk.annotations.Internal;

/**
* Atomically tracks the dirty-state of a metric.
Expand All @@ -42,7 +43,8 @@
* completed.
*/
@Experimental(Kind.METRICS)
class DirtyState implements Serializable {
@Internal
public class DirtyState implements Serializable {
private enum State {
/** Indicates that there have been changes to the MetricCell since last commit. */
DIRTY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import java.util.concurrent.atomic.AtomicReference;
import org.apache.beam.sdk.annotations.Experimental;
import org.apache.beam.sdk.annotations.Experimental.Kind;
import org.apache.beam.sdk.annotations.Internal;
import org.apache.beam.sdk.metrics.Distribution;
import org.apache.beam.sdk.metrics.MetricName;
import org.apache.beam.sdk.metrics.MetricsContainer;

/**
* Tracks the current value (and delta) for a Distribution metric.
Expand All @@ -41,10 +43,12 @@ public class DistributionCell implements Distribution, MetricCell<DistributionDa
private final MetricName name;

/**
* Package-visibility because all {@link DistributionCell DistributionCells} should be created by
* {@link MetricsContainerImpl#getDistribution(MetricName)}.
* Generally, runners should construct instances using the methods in
* {@link MetricsContainerImpl}, unless they need to define their own version of
* {@link MetricsContainer}. These constructors are *only* public so runners can instantiate.
*/
DistributionCell(MetricName name) {
@Internal
public DistributionCell(MetricName name) {
this.name = name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

import java.util.concurrent.atomic.AtomicReference;
import org.apache.beam.sdk.annotations.Experimental;
import org.apache.beam.sdk.annotations.Internal;
import org.apache.beam.sdk.metrics.Gauge;
import org.apache.beam.sdk.metrics.MetricName;
import org.apache.beam.sdk.metrics.MetricsContainer;

/**
* Tracks the current value (and delta) for a {@link Gauge} metric.
Expand All @@ -39,10 +41,12 @@ public class GaugeCell implements Gauge, MetricCell<GaugeData> {
private final MetricName name;

/**
* Package-visibility because all {@link GaugeCell GaugeCells} should be created by
* {@link MetricsContainerImpl#getGauge(MetricName)}.
* Generally, runners should construct instances using the methods in
* {@link MetricsContainerImpl}, unless they need to define their own version of
* {@link MetricsContainer}. These constructors are *only* public so runners can instantiate.
*/
GaugeCell(MetricName name) {
@Internal
public GaugeCell(MetricName name) {
this.name = name;
}

Expand Down Expand Up @@ -70,7 +74,6 @@ public GaugeData getCumulative() {
return gaugeValue.get();
}


@Override
public MetricName getName() {
return name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import org.apache.beam.sdk.metrics.MetricsContainer;

/**
* Holds the metrics for a single step and unit-of-commit (bundle).
* Holds the metrics for a single step and uses metric cells that allow extracting the cumulative
* value. Generally, this implementation should be used for a specific unit of commitment (bundle)
* that wishes to report the values since the start of the bundle (eg., for committed metrics).
*
* <p>This class is thread-safe. It is intended to be used with 1 (or more) threads are updating
* metrics and at-most 1 thread is extracting updates by calling {@link #getUpdates} and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import org.apache.beam.sdk.annotations.Experimental.Kind;

/**
* Holds the metrics for a single step and unit-of-commit (bundle).
* Holds the metrics for a single step. Each of the methods should return an implementation of the
* appropriate metrics interface for the "current" step.
*/
@Experimental(Kind.METRICS)
public interface MetricsContainer extends Serializable {
Expand Down