mirror of
https://github.com/valitydev/exporter-business-metrics.git
synced 2024-11-06 00:55:19 +00:00
add logs, add exlude mocketbank
This commit is contained in:
parent
e53c81e2f6
commit
6a2065a52f
@ -37,6 +37,7 @@ import javax.persistence.*;
|
||||
inner join dw.payment_route as pr
|
||||
on p2.invoice_id = pr.invoice_id and
|
||||
p2.payment_id = pr.payment_id and
|
||||
pr.route_provider_id not in (1) and
|
||||
pr.current)
|
||||
select p3.*,
|
||||
p.name as provider_name
|
||||
@ -79,9 +80,9 @@ import javax.persistence.*;
|
||||
issuer_bank,
|
||||
status
|
||||
""",
|
||||
resultSetMapping = "PaymentsMetricDto")
|
||||
resultSetMapping = "PaymentsMetricDtoList")
|
||||
@SqlResultSetMapping(
|
||||
name = "PaymentsMetricDto",
|
||||
name = "PaymentsMetricDtoList",
|
||||
classes = @ConstructorResult(
|
||||
targetClass = PaymentsMetricDto.class,
|
||||
columns = {
|
||||
|
@ -17,6 +17,7 @@ import java.util.function.ToDoubleFunction;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@SuppressWarnings("LineLength")
|
||||
public class PaymentService {
|
||||
|
||||
@Value("${interval.time}")
|
||||
@ -26,12 +27,25 @@ public class PaymentService {
|
||||
|
||||
public void registerMetrics(MeterRegistry meterRegistry) {
|
||||
var paymentsMetrics = paymentRepository.getPaymentsMetricsByInterval(intervalTime);
|
||||
log.info("Actual payments metrics by {} seconds interval size = {}", intervalTime, paymentsMetrics.toString());
|
||||
paymentsMetrics.forEach(dto -> Gauge.builder(Metric.PAYMENTS_COUNT.getName(), dto, getValue())
|
||||
.description(Metric.PAYMENTS_COUNT.getDescription())
|
||||
.baseUnit(Metric.PAYMENTS_COUNT.getUnit())
|
||||
.tags(getTags(dto))
|
||||
.register(meterRegistry));
|
||||
log.info("Actual payments metrics have been got from 'daway' db, " +
|
||||
"interval = {}, count = {}", intervalTime, paymentsMetrics.size());
|
||||
int pendingCount = 0;
|
||||
int failedCount = 0;
|
||||
int capturedCount = 0;
|
||||
for (PaymentsMetricDto dto : paymentsMetrics) {
|
||||
switch (dto.getStatus()) {
|
||||
case "pending" -> pendingCount++;
|
||||
case "captured" -> capturedCount++;
|
||||
case "failed" -> failedCount++;
|
||||
}
|
||||
Gauge.builder(Metric.PAYMENTS_COUNT.getName(), dto, getValue())
|
||||
.description(Metric.PAYMENTS_COUNT.getDescription())
|
||||
.baseUnit(Metric.PAYMENTS_COUNT.getUnit())
|
||||
.tags(getTags(dto))
|
||||
.register(meterRegistry);
|
||||
}
|
||||
log.info("Actual payments metrics have been registered to 'prometheus', " +
|
||||
"pendingCount = {}, failedCount = {}, capturedCount = {}", pendingCount, failedCount, capturedCount);
|
||||
}
|
||||
|
||||
private ToDoubleFunction<PaymentsMetricDto> getValue() {
|
||||
|
Loading…
Reference in New Issue
Block a user