Skip to content

Commit bfd8926

Browse files
author
Sina Kashipazha
committed
Removed redundant lines of the Prometheus outputs.
1 parent 633ebac commit bfd8926

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterImpl.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.HashMap;
2222
import java.util.List;
2323
import java.util.Map;
24+
import java.util.stream.Collectors;
2425

2526
import javax.inject.Inject;
2627

@@ -251,10 +252,12 @@ private void addVMMetrics(final List<Item> metricsList, final long dcId, final S
251252
}
252253
metricsList.add(new ItemVM(zoneName, zoneUuid, state.name().toLowerCase(), count));
253254
}
254-
List<String> allHostTags = new ArrayList<String>();
255-
for (final HostVO host : hostDao.listAll()) {
256-
allHostTags.addAll(_hostTagsDao.gethostTags(host.getId()));
257-
}
255+
256+
List<String> allHostTags = hostDao.listAll().stream()
257+
.flatMap( h -> _hostTagsDao.gethostTags(h.getId()).stream())
258+
.distinct()
259+
.collect(Collectors.toList());
260+
258261
for (final State state : State.values()) {
259262
for (final String hosttag : allHostTags) {
260263
final Long count = vmDao.countByZoneAndStateAndHostTag(dcId, state, hosttag);

0 commit comments

Comments
 (0)