Skip to content

Commit

Permalink
Memoize toString() for MetricKey and MetricName (#32379)
Browse files Browse the repository at this point in the history
  • Loading branch information
FuRyanf authored Aug 31, 2024
1 parent e18596c commit 64b4aa6
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.checkerframework.checker.nullness.qual.Nullable;

Expand All @@ -32,7 +33,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.v32_1_2_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.vendor.guava.v32_1_2_jre.com.google.common.base.Strings;

Expand All @@ -39,6 +40,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 64b4aa6

Please sign in to comment.