Skip to content

Commit

Permalink
Memoize toString() for MetricKey and MetricName (apache#32379)
Browse files Browse the repository at this point in the history
(cherry picked from commit 64b4aa6)
  • Loading branch information
FuRyanf authored and ModRyanFu committed Sep 3, 2024
1 parent 0a54c22 commit b3d31dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.beam.sdk.metrics;

import com.google.auto.value.AutoValue;
import com.google.auto.value.extension.memoized.Memoized;
import java.io.Serializable;
import org.apache.beam.sdk.annotations.Experimental;
import org.apache.beam.sdk.annotations.Experimental.Kind;
Expand All @@ -35,7 +36,8 @@ public abstract class MetricKey implements Serializable {
public abstract MetricName metricName();

@Override
public final String toString() {
@Memoized
public String toString() {
return stepName() + ":" + metricName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument;

import com.google.auto.value.AutoValue;
import com.google.auto.value.extension.memoized.Memoized;
import java.io.Serializable;
import org.apache.beam.sdk.annotations.Experimental;
import org.apache.beam.sdk.annotations.Experimental.Kind;
Expand All @@ -42,6 +43,7 @@ public abstract class MetricName implements Serializable {
public abstract String getName();

@Override
@Memoized
public String toString() {
return getNamespace() + ":" + getName();
}
Expand Down

0 comments on commit b3d31dd

Please sign in to comment.