Skip to content

Commit 1901ab5

Browse files
author
iliax
committed
StatisticsServiceTest, PrometheusMetricsRetrieverTest fix
1 parent 917fb19 commit 1901ab5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

api/src/main/java/io/kafbat/ui/service/metrics/scrape/prometheus/PrometheusMetricsRetriever.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ Mono<List<MetricSnapshot>> retrieve(String host) {
4848
.bodyToMono(String.class)
4949
.doOnError(e -> log.error("Error while getting metrics from {}", host, e))
5050
.map(body -> new PrometheusTextFormatParser().parse(body))
51-
.onErrorResume(th -> Mono.just(List.of()));
51+
.onErrorResume(th -> {
52+
log.warn("Error while getting prometheus metrics from {}", host, th);
53+
return Mono.just(List.of());
54+
});
5255
}
5356
}

api/src/main/java/io/kafbat/ui/service/metrics/scrape/prometheus/PrometheusTextFormatParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private void parseMetricLine(String line, ParsingContext cxt) {
101101
String timestampString = m.group(4);
102102
cxt.dataPoint(
103103
new ParsedDataPoint(
104-
PrometheusNaming.sanitizeMetricName(metricName),
104+
metricName,
105105
Optional.ofNullable(labelsString).map(this::parseLabels).orElse(Labels.EMPTY),
106106
parseDouble(valueString),
107107
Optional.ofNullable(timestampString).map(Long::parseLong).orElse(0L)));
@@ -180,7 +180,7 @@ void metricNameAndHelp(String metricName, String help) {
180180

181181
void dataPoint(ParsedDataPoint parsedDataPoint) {
182182
if (currentMetricName == null) {
183-
currentMetricName = parsedDataPoint.name;
183+
currentMetricName = PrometheusNaming.sanitizeMetricName(parsedDataPoint.name);
184184
}
185185
if (dataPoints == null) {
186186
dataPoints = new UntypedDataPointsAccumulator();

0 commit comments

Comments
 (0)