Skip to content

Commit

Permalink
Cache toString() for MetricKey and MetricName in instance variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ModRyanFu committed Aug 30, 2024
1 parent 10074a9 commit a7a4293
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class BeamModulePlugin implements Plugin<Project> {

// Automatically use the official release version if we are performing a release
// otherwise append '-SNAPSHOT'
project.version = '2.45.24'
project.version = '2.45.25'
if (isLinkedin(project)) {
project.ext.mavenGroupId = 'com.linkedin.beam'
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ signing.gnupg.useLegacyGpg=true
# buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy.
# To build a custom Beam version make sure you change it in both places, see
# https://github.com/apache/beam/issues/21302.
version=2.45.24
sdk_version=2.45.24
version=2.45.25
sdk_version=2.45.25

javaVersion=1.8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
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;
import org.checkerframework.checker.nullness.qual.Nullable;


/** Metrics are keyed by the step name they are associated with and the name of the metric. */
@Experimental(Kind.METRICS)
@AutoValue
Expand All @@ -35,6 +37,7 @@ public abstract class MetricKey implements Serializable {
public abstract MetricName metricName();

@Override
@Memoized
public final String toString() {
return stepName() + ":" + metricName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
*/
package org.apache.beam.sdk.metrics;

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;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Strings;

import static org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.*;


/**
* The name of a metric consists of a {@link #getNamespace} and a {@link #getName}. The {@link
* #getNamespace} allows grouping related metrics together and also prevents collisions between
Expand All @@ -42,6 +44,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 a7a4293

Please sign in to comment.