diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryProducer.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryProducer.java index 4df1f69659ba9..dd3da134b07a0 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryProducer.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryProducer.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.function.BiFunction; +import java.util.function.Function; import jakarta.enterprise.inject.Any; import jakarta.enterprise.inject.Instance; @@ -154,10 +155,20 @@ private Map getOtelConfigs() { if (configValue.getValue() != null) { NameIterator name = new NameIterator(propertyName); name.next(); - oTelConfigs.put(name.getName().substring(name.getPosition() + 1), configValue.getValue()); + String propertyValue = getConfigPropertyValue(propertyName, configValue); + oTelConfigs.put(name.getName().substring(name.getPosition() + 1), propertyValue); } } } return oTelConfigs; } + + private static String getConfigPropertyValue(String propertyName, ConfigValue smallRyeConfig) { + Function converter = OpenTelemetryUtil.OTEL_CONFIGURATION_AS_DURATION.get(propertyName); + if (converter == null) { + return smallRyeConfig.getValue(); + } else { + return converter.apply(smallRyeConfig.getValue()); + } + } } diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtil.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtil.java index 6ab6ffac43112..6e4f68230cd82 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtil.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtil.java @@ -1,14 +1,14 @@ package io.quarkus.opentelemetry.runtime; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.time.Duration; +import java.util.*; +import java.util.function.Function; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; import io.opentelemetry.sdk.trace.ReadableSpan; +import io.quarkus.runtime.configuration.DurationConverter; import io.quarkus.vertx.core.runtime.VertxMDC; public final class OpenTelemetryUtil { @@ -16,6 +16,19 @@ public final class OpenTelemetryUtil { public static final String SPAN_ID = "spanId"; public static final String SAMPLED = "sampled"; public static final String PARENT_ID = "parentId"; + public static final Map> OTEL_CONFIGURATION_AS_DURATION = Map.of( + "quarkus.otel.bsp.schedule.delay", + OpenTelemetryUtil::convertDuration, + "quarkus.otel.bsp.export.timeout", + OpenTelemetryUtil::convertDuration, + "quarkus.otel.exporter.otlp.traces.timeout", + OpenTelemetryUtil::convertDuration + ); + + static String convertDuration(String propertyValue) { + Duration duration = DurationConverter.parseDuration(propertyValue); + return Long.toString(duration.toMillis()).concat("ms"); + }; private OpenTelemetryUtil() { }