mirror of
https://github.com/valitydev/exporter-limits.git
synced 2024-11-06 00:25:22 +00:00
refactor logs
This commit is contained in:
parent
9fbdca7469
commit
7f40ca1916
@ -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 {
|
||||||
|
|
||||||
|
}
|
@ -6,12 +6,12 @@ import lombok.RequiredArgsConstructor;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public enum Metric {
|
public enum Metric {
|
||||||
|
|
||||||
LIMITS_BOUNDARY(
|
CALENDAR_LIMITS_BOUNDARY(
|
||||||
formatWithPrefix("limits_boundary_by_calendar"),
|
formatWithPrefix("limits_boundary_by_calendar"),
|
||||||
"Limits boundary since last scrape"),
|
"Calendar limits boundary since last scrape"),
|
||||||
LIMITS_AMOUNT(
|
CALENDAR_LIMITS_AMOUNT(
|
||||||
formatWithPrefix("limits_amount_by_calendar"),
|
formatWithPrefix("limits_amount_by_calendar"),
|
||||||
"Limits amount since last scrape");
|
"Calendar limits amount since last scrape");
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@ -36,14 +36,11 @@ public class LimitsService {
|
|||||||
|
|
||||||
public void registerMetrics() {
|
public void registerMetrics() {
|
||||||
var limitsDataByInterval = openSearchService.getLimitsDataByInterval();
|
var limitsDataByInterval = openSearchService.getLimitsDataByInterval();
|
||||||
log.info("limitsDataByInterval {}", limitsDataByInterval);
|
|
||||||
var limitConfigIds = limitsDataByInterval.stream()
|
var limitConfigIds = limitsDataByInterval.stream()
|
||||||
.map(limitsData -> limitsData.getLimit().getConfigId())
|
.map(limitsData -> limitsData.getLimit().getConfigId())
|
||||||
.distinct()
|
.distinct()
|
||||||
.toList();
|
.toList();
|
||||||
log.info("limitConfigIds {}", limitConfigIds);
|
|
||||||
var limitConfigEntities = limitConfigRepository.findAllUsingLimitConfigIdsAndTimeRangType(limitConfigIds, TimeRangeType.calendar);
|
var limitConfigEntities = limitConfigRepository.findAllUsingLimitConfigIdsAndTimeRangType(limitConfigIds, TimeRangeType.calendar);
|
||||||
log.info("limitConfigEntities {}", limitConfigEntities);
|
|
||||||
var limitConfigsById = limitConfigEntities.stream().collect(
|
var limitConfigsById = limitConfigEntities.stream().collect(
|
||||||
Collectors.groupingBy(
|
Collectors.groupingBy(
|
||||||
o -> o.getPk().getLimitConfigId(),
|
o -> o.getPk().getLimitConfigId(),
|
||||||
@ -54,11 +51,10 @@ public class LimitsService {
|
|||||||
values -> values.stream()
|
values -> values.stream()
|
||||||
.max(Comparator.comparing(limitConfigEntity -> limitConfigEntity.getPk().getSequenceId()))
|
.max(Comparator.comparing(limitConfigEntity -> limitConfigEntity.getPk().getSequenceId()))
|
||||||
.orElse(null)))));
|
.orElse(null)))));
|
||||||
log.info("limitConfigsById {}", limitConfigsById);
|
|
||||||
for (var limitsData : limitsDataByInterval) {
|
for (var limitsData : limitsDataByInterval) {
|
||||||
var limitConfigEntity = limitConfigsById.get(limitsData.getLimit().getConfigId());
|
var limitConfigEntity = limitConfigsById.get(limitsData.getLimit().getConfigId());
|
||||||
if (limitConfigEntity == null) {
|
if (limitConfigEntity == null) {
|
||||||
log.info("limitConfigEntity null, limitsData {}", limitsData);
|
log.warn("limitConfigEntity null, no gauge limitsData {}", limitsData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var id = String.format(
|
var id = String.format(
|
||||||
@ -68,11 +64,10 @@ public class LimitsService {
|
|||||||
limitsData.getLimit().getRoute().getTerminalId(),
|
limitsData.getLimit().getRoute().getTerminalId(),
|
||||||
limitsData.getLimit().getShopId(),
|
limitsData.getLimit().getShopId(),
|
||||||
limitsData.getLimit().getChange().getCurrency());
|
limitsData.getLimit().getChange().getCurrency());
|
||||||
log.info("id {}", id);
|
gauge(limitsBoundaryAggregatesMap, Metric.CALENDAR_LIMITS_BOUNDARY, id, getTags(limitsData, limitConfigEntity), limitsData.getLimit().getBoundary());
|
||||||
gauge(limitsBoundaryAggregatesMap, Metric.LIMITS_BOUNDARY, id, getTags(limitsData, limitConfigEntity), limitsData.getLimit().getBoundary());
|
gauge(limitsAmountAggregatesMap, Metric.CALENDAR_LIMITS_AMOUNT, id, getTags(limitsData, limitConfigEntity), limitsData.getLimit().getAmount());
|
||||||
gauge(limitsAmountAggregatesMap, Metric.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', " +
|
log.info("Limits metrics have been registered to 'prometheus', " +
|
||||||
"registeredMetricsSize = {}, clientSize = {}", registeredMetricsSize, limitsDataByInterval.size());
|
"registeredMetricsSize = {}, clientSize = {}", registeredMetricsSize, limitsDataByInterval.size());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user