scwhittle commented on code in PR #33503:
URL: https://github.com/apache/beam/pull/33503#discussion_r1970452713
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/RpcQosImpl.java:
##########
@@ -1068,5 +1069,10 @@ public String getNamespace() {
public String getName() {
return name;
}
+
+ @Override
+ public HashMap<String, String> getLabels() {
+ return new HashMap<>();
Review Comment:
ImmutableMap.of() is a singleton
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/LabeledMetricNameUtils.java:
##########
@@ -42,6 +43,7 @@ public class LabeledMetricNameUtils {
*/
public static class MetricNameBuilder {
private final StringBuilder labeledNameBuilder;
+ private HashMap<String, String> metricLabels = new HashMap<String,
String>();
Review Comment:
How about ImmutableMap builder? and then build to immutable map below?
##########
sdks/java/io/kafka/build.gradle:
##########
@@ -52,6 +52,7 @@ dependencies {
provided library.java.jackson_dataformat_csv
permitUnusedDeclared library.java.jackson_dataformat_csv
implementation project(path: ":sdks:java:core", configuration: "shadow")
+ implementation project(path: ":runners:core-java")
Review Comment:
I would appreciate someone more familiar with desired deps structure to
review this.
It might be preferrable to move the constants to somewhere in core out of
runners
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/LabeledMetricNameUtils.java:
##########
@@ -63,8 +65,12 @@ public void addLabel(String key, String value) {
.append(LABEL_DELIMITER);
}
+ public void addMetricLabel(String key, String value) {
Review Comment:
needs a comment, it is a little confusing on how this is different from
addLabel
##########
sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricName.java:
##########
@@ -48,12 +53,24 @@ public String toString() {
public static MetricName named(String namespace, String name) {
checkArgument(!Strings.isNullOrEmpty(namespace), "Metric namespace must be
non-empty");
checkArgument(!Strings.isNullOrEmpty(name), "Metric name must be
non-empty");
- return new AutoValue_MetricName(namespace, name);
+ return new AutoValue_MetricName(namespace, name, new HashMap<String,
String>());
+ }
+
+ public static MetricName named(String namespace, String name,
HashMap<String, String> labels) {
Review Comment:
change the map type to immutablemap throughout (change to ImmutableMap.of()
for the empty ones)
Nice to have immutable to avoid possible changes to the labels. And it is
optimized for small maps
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]