From 7f40ca191696a3f7beeee9a084d0f517ed8205c6 Mon Sep 17 00:00:00 2001 From: Anatoly Karlov Date: Thu, 17 Aug 2023 18:15:23 +0300 Subject: [PATCH] refactor logs --- .../vality/exporter/limits/config/CacheConfig.java | 10 ++++++++++ .../dev/vality/exporter/limits/model/Metric.java | 8 ++++---- .../exporter/limits/service/LimitsService.java | 13 ++++--------- 3 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 src/main/java/dev/vality/exporter/limits/config/CacheConfig.java diff --git a/src/main/java/dev/vality/exporter/limits/config/CacheConfig.java b/src/main/java/dev/vality/exporter/limits/config/CacheConfig.java new file mode 100644 index 0000000..b30537c --- /dev/null +++ b/src/main/java/dev/vality/exporter/limits/config/CacheConfig.java @@ -0,0 +1,10 @@ +package dev.vality.exporter.limits.config; + +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableCaching +public class CacheConfig { + +} diff --git a/src/main/java/dev/vality/exporter/limits/model/Metric.java b/src/main/java/dev/vality/exporter/limits/model/Metric.java index e66c851..123b66d 100644 --- a/src/main/java/dev/vality/exporter/limits/model/Metric.java +++ b/src/main/java/dev/vality/exporter/limits/model/Metric.java @@ -6,12 +6,12 @@ import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public enum Metric { - LIMITS_BOUNDARY( + CALENDAR_LIMITS_BOUNDARY( formatWithPrefix("limits_boundary_by_calendar"), - "Limits boundary since last scrape"), - LIMITS_AMOUNT( + "Calendar limits boundary since last scrape"), + CALENDAR_LIMITS_AMOUNT( formatWithPrefix("limits_amount_by_calendar"), - "Limits amount since last scrape"); + "Calendar limits amount since last scrape"); @Getter private final String name; diff --git a/src/main/java/dev/vality/exporter/limits/service/LimitsService.java b/src/main/java/dev/vality/exporter/limits/service/LimitsService.java index b1919d7..4b5af8b 100644 --- a/src/main/java/dev/vality/exporter/limits/service/LimitsService.java +++ b/src/main/java/dev/vality/exporter/limits/service/LimitsService.java @@ -36,14 +36,11 @@ public class LimitsService { public void registerMetrics() { var limitsDataByInterval = openSearchService.getLimitsDataByInterval(); - log.info("limitsDataByInterval {}", limitsDataByInterval); var limitConfigIds = limitsDataByInterval.stream() .map(limitsData -> limitsData.getLimit().getConfigId()) .distinct() .toList(); - log.info("limitConfigIds {}", limitConfigIds); var limitConfigEntities = limitConfigRepository.findAllUsingLimitConfigIdsAndTimeRangType(limitConfigIds, TimeRangeType.calendar); - log.info("limitConfigEntities {}", limitConfigEntities); var limitConfigsById = limitConfigEntities.stream().collect( Collectors.groupingBy( o -> o.getPk().getLimitConfigId(), @@ -54,11 +51,10 @@ public class LimitsService { values -> values.stream() .max(Comparator.comparing(limitConfigEntity -> limitConfigEntity.getPk().getSequenceId())) .orElse(null))))); - log.info("limitConfigsById {}", limitConfigsById); for (var limitsData : limitsDataByInterval) { var limitConfigEntity = limitConfigsById.get(limitsData.getLimit().getConfigId()); if (limitConfigEntity == null) { - log.info("limitConfigEntity null, limitsData {}", limitsData); + log.warn("limitConfigEntity null, no gauge limitsData {}", limitsData); break; } var id = String.format( @@ -68,11 +64,10 @@ public class LimitsService { limitsData.getLimit().getRoute().getTerminalId(), limitsData.getLimit().getShopId(), limitsData.getLimit().getChange().getCurrency()); - log.info("id {}", id); - gauge(limitsBoundaryAggregatesMap, Metric.LIMITS_BOUNDARY, id, getTags(limitsData, limitConfigEntity), limitsData.getLimit().getBoundary()); - gauge(limitsAmountAggregatesMap, Metric.LIMITS_AMOUNT, id, getTags(limitsData, limitConfigEntity), limitsData.getLimit().getAmount()); + gauge(limitsBoundaryAggregatesMap, Metric.CALENDAR_LIMITS_BOUNDARY, id, getTags(limitsData, limitConfigEntity), limitsData.getLimit().getBoundary()); + gauge(limitsAmountAggregatesMap, Metric.CALENDAR_LIMITS_AMOUNT, id, getTags(limitsData, limitConfigEntity), limitsData.getLimit().getAmount()); } - var registeredMetricsSize = meterRegistryService.getRegisteredMetricsSize(Metric.LIMITS_BOUNDARY.getName()) + meterRegistryService.getRegisteredMetricsSize(Metric.LIMITS_AMOUNT.getName()); + var registeredMetricsSize = meterRegistryService.getRegisteredMetricsSize(Metric.CALENDAR_LIMITS_BOUNDARY.getName()) + meterRegistryService.getRegisteredMetricsSize(Metric.CALENDAR_LIMITS_AMOUNT.getName()); log.info("Limits metrics have been registered to 'prometheus', " + "registeredMetricsSize = {}, clientSize = {}", registeredMetricsSize, limitsDataByInterval.size()); }