lukecwik commented on a change in pull request #17094:
URL: https://github.com/apache/beam/pull/17094#discussion_r829197254



##########
File path: 
runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MonitoringInfoMetricName.java
##########
@@ -56,13 +58,13 @@ private MonitoringInfoMetricName(String urn, Map<String, 
String> labels) {
   public String getNamespace() {
     if (labels.containsKey(MonitoringInfoConstants.Labels.NAMESPACE)) {

Review comment:
       Don't pay the map lookup cost twice:
   ```
   String rval = labels.get(KEY1);
   if (rval != null) {
     return rval;
   }
   rval = labels.get(KEY2);
   if (rval != null) {
     return rval;
   }
   ...
   ```

##########
File path: 
runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MonitoringInfoMetricName.java
##########
@@ -48,6 +45,11 @@ private MonitoringInfoMetricName(String urn, Map<String, 
String> labels) {
     // and ensure all necessary labels are set for the specific URN.
     this.urn = urn;
     for (Entry<String, String> entry : labels.entrySet()) {

Review comment:
       this.labels = ImmutableMap.copyOf(labels);

##########
File path: 
runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MonitoringInfoMetricName.java
##########
@@ -33,9 +33,6 @@
  * key instead of only a name+namespace. This is useful when defining system 
defined metrics with a
  * specific urn via a {@code CounterContainer}.
  */
-@SuppressWarnings({
-  "nullness" // TODO(https://issues.apache.org/jira/browse/BEAM-10402)
-})
 public class MonitoringInfoMetricName extends MetricName {
 
   private String urn;

Review comment:
       mark these fields final




-- 
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]


Reply via email to