Skip to content

Commit 5867b79

Browse files
dhoardfstab
authored andcommitted
Simple MetricsSnapshot performance change
Signed-off-by: dhoard <[email protected]>
1 parent fa5e057 commit 5867b79

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/MetricSnapshots.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ private Builder() {
7979
}
8080

8181
public boolean containsMetricName(String name) {
82+
if (name == null) {
83+
return false;
84+
}
85+
String prometheusName = prometheusName(name);
8286
for (MetricSnapshot snapshot : snapshots) {
83-
if (snapshot.getMetadata().getPrometheusName().equals(prometheusName(name))) {
87+
if (snapshot.getMetadata().getPrometheusName().equals(prometheusName)) {
8488
return true;
8589
}
8690
}

0 commit comments

Comments
 (0)