未验证 提交 bf0e22d2 编写于 作者: H Huang 提交者: GitHub

Fix IllegalArgumentException in PrometheusMetricConverter and NaN value...

Fix IllegalArgumentException in PrometheusMetricConverter and NaN value samples in SampleFamily (#7349)
上级 3704567b
......@@ -113,6 +113,8 @@ Release Notes.
new timeout mechanism is designed for avoiding this specific case.
* Fix Kafka transport topics are created duplicated with and without namespace issue
* Fix possible version_conflict_engine_exception in bulk execution.
* Fix PrometheusMetricConverter may throw an `IllegalArgumentException` when convert metrics to SampleFamily
* Filtering NaN value samples when build SampleFamily
#### UI
......
......@@ -74,6 +74,7 @@ public class SampleFamily {
static SampleFamily build(RunningContext ctx, Sample... samples) {
Preconditions.checkNotNull(samples);
samples = Arrays.stream(samples).filter(sample -> !Double.isNaN(sample.getValue())).toArray(Sample[]::new);
Preconditions.checkArgument(samples.length > 0);
return new SampleFamily(samples, Optional.ofNullable(ctx).orElseGet(RunningContext::instance));
}
......
......@@ -88,7 +88,7 @@ public class PrometheusMetricConverter {
return metricStream
.peek(metric -> log.debug("Prom metric to be convert to SampleFamily: {}", metric))
.flatMap(this::convertMetric)
.filter(t -> t != NIL)
.filter(t -> t != NIL && t._2.samples.length > 0)
.peek(t -> log.debug("SampleFamily: {}", t))
.collect(toImmutableMap(Tuple2::_1, Tuple2::_2, (a, b) -> {
log.debug("merge {} {}", a, b);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册