|
12 | 12 | import java.util.Map.Entry; |
13 | 13 | import java.util.concurrent.TimeUnit; |
14 | 14 | import java.util.concurrent.atomic.AtomicLong; |
| 15 | +import java.util.logging.Logger; |
15 | 16 | import java.util.stream.Collectors; |
16 | 17 | import org.phoebus.channelfinder.repository.ChannelRepository; |
17 | 18 | import org.phoebus.channelfinder.repository.PropertyRepository; |
18 | 19 | import org.phoebus.channelfinder.repository.TagRepository; |
19 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
20 | 21 | import org.springframework.beans.factory.annotation.Value; |
21 | | -import org.springframework.context.annotation.PropertySource; |
22 | 22 | import org.springframework.scheduling.annotation.Scheduled; |
23 | 23 | import org.springframework.stereotype.Service; |
24 | 24 | import org.springframework.util.LinkedMultiValueMap; |
25 | 25 | import org.springframework.util.MultiValueMap; |
26 | 26 |
|
27 | 27 | @Service |
28 | | -@PropertySource(value = "classpath:application.properties") |
29 | 28 | public class MetricsService { |
30 | | - |
31 | 29 | public static final String CF_TOTAL_CHANNEL_COUNT = "cf.total.channel.count"; |
32 | 30 | public static final String CF_PROPERTY_COUNT = "cf.property.count"; |
33 | 31 | public static final String CF_TAG_COUNT = "cf.tag.count"; |
@@ -60,7 +58,7 @@ public class MetricsService { |
60 | 58 |
|
61 | 59 | Map<String, List<String>> parseProperties() { |
62 | 60 | if (metricProperties == null || metricProperties.isEmpty()) { |
63 | | - return new LinkedMultiValueMap<>(); |
| 61 | + return Map.of(); |
64 | 62 | } |
65 | 63 | return Arrays.stream(metricProperties.split(";")) |
66 | 64 | .map( |
@@ -121,9 +119,7 @@ public static List<MultiValueMap<String, String>> generateAllMultiValueMaps( |
121 | 119 | List<MultiValueMap<String, String>> allMultiValueMaps = new ArrayList<>(); |
122 | 120 |
|
123 | 121 | if (properties.isEmpty()) { |
124 | | - allMultiValueMaps.add( |
125 | | - new LinkedMultiValueMap<>()); // Add an empty map for the case where all are null |
126 | | - return allMultiValueMaps; |
| 122 | + return List.of(); |
127 | 123 | } |
128 | 124 |
|
129 | 125 | List<Entry<String, List<String>>> entries = new ArrayList<>(properties.entrySet()); |
@@ -211,7 +207,11 @@ private void updatePropertyMetrics() { |
211 | 207 |
|
212 | 208 | @Scheduled(fixedRateString = "${metrics.updateInterval}", timeUnit = TimeUnit.SECONDS) |
213 | 209 | public void updateMetrics() { |
214 | | - updateTagMetrics(); |
215 | | - updatePropertyMetrics(); |
| 210 | + if (tagMetrics != null && !tagMetrics.isEmpty()) { |
| 211 | + updateTagMetrics(); |
| 212 | + } |
| 213 | + if (propertyMetrics != null && !propertyMetrics.isEmpty()) { |
| 214 | + updatePropertyMetrics(); |
| 215 | + } |
216 | 216 | } |
217 | 217 | } |
0 commit comments