Fix IllegalArgumentException in PrometheusMetricConverter and NaN value samples in SampleFamily (#7349)

This commit is contained in:
Huang 2021-07-21 23:14:49 +08:00 committed by GitHub
parent 3704567b21
commit bf0e22d2c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 1 deletions

View File

@ -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

View File

@ -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));
}

View File

@ -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);