Skip to content

Commit

Permalink
Fix NullPointerException in OpenTelemetry exporter
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Stäber <[email protected]>
  • Loading branch information
fstab committed Mar 22, 2024
1 parent 5b286bc commit 5102909
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import io.prometheus.metrics.shaded.io_opentelemetry_1_31_0.sdk.metrics.data.PointData;
import io.prometheus.metrics.shaded.io_opentelemetry_1_31_0.sdk.metrics.internal.data.ImmutableDoubleExemplarData;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
Expand Down Expand Up @@ -43,13 +43,15 @@ protected Attributes labelsToAttributes(Labels labels) {
}

protected List<DoubleExemplarData> convertExemplar(Exemplar exemplar) {
if (exemplar == null) {
return Collections.emptyList();
}
return convertExemplars(Exemplars.of(exemplar));
}

protected List<DoubleExemplarData> convertExemplars(Exemplars exemplars) {
return StreamSupport.stream(exemplars.spliterator(), false)
.map(this::toDoubleExemplarData)
.filter(Objects::nonNull)
.collect(Collectors.toList());
}

Expand Down

0 comments on commit 5102909

Please sign in to comment.