compression();
+
+ /**
+ * Sets the maximum time to wait for the collector to process an exported batch of spans. If
+ * unset, defaults to {@value OtlpExporterRuntimeConfig#DEFAULT_TIMEOUT_SECS}s.
+ */
+ @Override
+ @WithDefault("10s")
+ Duration timeout();
+
+ /**
+ * OTLP defines the encoding of telemetry data and the protocol used to exchange data between the client and the
+ * server. Depending on the exporter, the available protocols will be different.
+ *
+ * Currently, only {@code grpc} and {@code http/protobuf} are allowed.
+ */
+ @Override
+ @WithDefault(OtlpExporterConfig.Protocol.GRPC)
+ Optional protocol();
+
+ /**
+ * Key/cert configuration in the PEM format.
+ */
+ @Override
+ @WithName("key-cert")
+ OtlpExporterConfig.KeyCert keyCert();
+
+ /**
+ * Trust configuration in the PEM format.
+ */
+ @Override
+ @WithName("trust-cert")
+ OtlpExporterConfig.TrustCert trustCert();
+
+ /**
+ * The name of the TLS configuration to use.
+ *
+ * If not set and the default TLS configuration is configured ({@code quarkus.tls.*}) then that will be used.
+ * If a name is configured, it uses the configuration from {@code quarkus.tls..*}
+ * If a name is configured, but no TLS configuration is found with that name then an error will be thrown.
+ */
+ @Override
+ Optional tlsConfigurationName();
+
+ /**
+ * Set proxy options
+ */
+ @Override
+ OtlpExporterConfig.ProxyConfig proxyOptions();
+
/**
* OTLP traces exporter configuration.
*/
diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterTracesConfig.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterTracesConfig.java
index 12eac3685da91..4371c78b44111 100644
--- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterTracesConfig.java
+++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterTracesConfig.java
@@ -1,22 +1,7 @@
package io.quarkus.opentelemetry.runtime.config.runtime.exporter;
-import static io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterRuntimeConfig.DEFAULT_GRPC_BASE_URI;
-
-import java.util.Optional;
-
import io.quarkus.runtime.annotations.ConfigGroup;
-import io.smallrye.config.WithDefault;
-import io.smallrye.config.WithName;
@ConfigGroup
public interface OtlpExporterTracesConfig extends OtlpExporterConfig {
-
- /**
- * See {@link OtlpExporterTracesConfig#endpoint}
- */
- // @WithConverter(TrimmedStringConverter.class)
- @Deprecated
- @WithName("legacy-endpoint")
- @WithDefault(DEFAULT_GRPC_BASE_URI)
- Optional legacyEndpoint();
}
diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OTelExporterRecorder.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OTelExporterRecorder.java
index 607c5f03ab95e..4d7d4956b61d5 100644
--- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OTelExporterRecorder.java
+++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OTelExporterRecorder.java
@@ -1,6 +1,5 @@
package io.quarkus.opentelemetry.runtime.exporter.otlp;
-import static io.opentelemetry.sdk.metrics.Aggregation.explicitBucketHistogram;
import static io.quarkus.opentelemetry.runtime.config.build.ExporterType.Constants.OTLP_VALUE;
import static io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterConfig.Protocol.GRPC;
import static io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterConfig.Protocol.HTTP_PROTOBUF;
@@ -67,13 +66,12 @@ public class OTelExporterRecorder {
public static final String BASE2EXPONENTIAL_AGGREGATION_NAME = AggregationUtil
.aggregationName(Aggregation.base2ExponentialBucketHistogram());
- public static final String EXPLICIT_BUCKET_AGGREGATION_NAME = AggregationUtil.aggregationName(explicitBucketHistogram());
public Function, LateBoundBatchSpanProcessor> batchSpanProcessorForOtlp(
OTelRuntimeConfig otelRuntimeConfig,
OtlpExporterRuntimeConfig exporterRuntimeConfig,
Supplier vertx) {
- URI baseUri = getBaseUri(exporterRuntimeConfig); // do the creation and validation here in order to preserve backward compatibility
+ URI baseUri = getTracesUri(exporterRuntimeConfig); // do the creation and validation here in order to preserve backward compatibility
return new Function<>() {
@Override
public LateBoundBatchSpanProcessor apply(
@@ -180,7 +178,7 @@ public Function, MetricExporter> crea
OtlpExporterRuntimeConfig exporterRuntimeConfig,
Supplier vertx) {
- final URI baseUri = getBaseUri(exporterRuntimeConfig);
+ final URI baseUri = getMetricsUri(exporterRuntimeConfig);
return new Function<>() {
@Override
@@ -311,22 +309,37 @@ private static Map populateTracingExportHttpHeaders(OtlpExporter
return headersMap;
}
- private URI getBaseUri(OtlpExporterRuntimeConfig exporterRuntimeConfig) {
- String endpoint = resolveEndpoint(exporterRuntimeConfig).trim(); // FIXME must be signal independent
+ private URI getTracesUri(OtlpExporterRuntimeConfig exporterRuntimeConfig) {
+ String endpoint = resolveTraceEndpoint(exporterRuntimeConfig);
if (endpoint.isEmpty()) {
return null;
}
return ExporterBuilderUtil.validateEndpoint(endpoint);
}
- static String resolveEndpoint(final OtlpExporterRuntimeConfig runtimeConfig) {
- String endpoint = runtimeConfig.traces().legacyEndpoint()
+ private URI getMetricsUri(OtlpExporterRuntimeConfig exporterRuntimeConfig) {
+ String endpoint = resolveTraceEndpoint(exporterRuntimeConfig);
+ if (endpoint.isEmpty()) {
+ return null;
+ }
+ return ExporterBuilderUtil.validateEndpoint(endpoint);
+ }
+
+ static String resolveTraceEndpoint(final OtlpExporterRuntimeConfig runtimeConfig) {
+ String endpoint = runtimeConfig.traces().endpoint()
+ .filter(OTelExporterRecorder::excludeDefaultEndpoint)
+ .orElse(runtimeConfig.endpoint()
+ .filter(OTelExporterRecorder::excludeDefaultEndpoint)
+ .orElse(DEFAULT_GRPC_BASE_URI));
+ return endpoint.trim();
+ }
+
+ static String resolveMetricEndpoint(final OtlpExporterRuntimeConfig runtimeConfig) {
+ String endpoint = runtimeConfig.metrics().endpoint()
.filter(OTelExporterRecorder::excludeDefaultEndpoint)
- .orElse(runtimeConfig.traces().endpoint()
+ .orElse(runtimeConfig.endpoint()
.filter(OTelExporterRecorder::excludeDefaultEndpoint)
- .orElse(runtimeConfig.endpoint()
- .filter(OTelExporterRecorder::excludeDefaultEndpoint)
- .orElse(DEFAULT_GRPC_BASE_URI)));
+ .orElse(DEFAULT_GRPC_BASE_URI));
return endpoint.trim();
}
diff --git a/extensions/opentelemetry/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor b/extensions/opentelemetry/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor
new file mode 100644
index 0000000000000..55782f5c4d6ec
--- /dev/null
+++ b/extensions/opentelemetry/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor
@@ -0,0 +1 @@
+io.quarkus.opentelemetry.runtime.config.HierarchicalOTelConnectionConfigInterceptor
diff --git a/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/config/HierarchicalOTelConnectionConfigInterceptorTest.java b/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/config/HierarchicalOTelConnectionConfigInterceptorTest.java
new file mode 100644
index 0000000000000..e509ebb35805a
--- /dev/null
+++ b/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/config/HierarchicalOTelConnectionConfigInterceptorTest.java
@@ -0,0 +1,62 @@
+package io.quarkus.opentelemetry.runtime.config;
+
+import static io.quarkus.opentelemetry.runtime.config.HierarchicalOTelConnectionConfigInterceptor.BASE;
+import static io.quarkus.opentelemetry.runtime.config.HierarchicalOTelConnectionConfigInterceptor.METRICS;
+import static io.quarkus.opentelemetry.runtime.config.HierarchicalOTelConnectionConfigInterceptor.MappingFunction;
+import static io.quarkus.opentelemetry.runtime.config.HierarchicalOTelConnectionConfigInterceptor.TRACES;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.jupiter.api.Test;
+
+class HierarchicalOTelConnectionConfigInterceptorTest {
+
+ private final static Map FALLBACKS = new HashMap<>();
+
+ static {
+ FALLBACKS.put(TRACES + "endpoint", BASE + "endpoint");
+ FALLBACKS.put(METRICS + "endpoint", BASE + "endpoint");
+ FALLBACKS.put(TRACES + "headers", BASE + "headers");
+ FALLBACKS.put(METRICS + "headers", BASE + "headers");
+ FALLBACKS.put(TRACES + "compression", BASE + "compression");
+ FALLBACKS.put(METRICS + "compression", BASE + "compression");
+ FALLBACKS.put(TRACES + "timeout", BASE + "timeout");
+ FALLBACKS.put(METRICS + "timeout", BASE + "timeout");
+ FALLBACKS.put(TRACES + "protocol", BASE + "protocol");
+ FALLBACKS.put(METRICS + "protocol", BASE + "protocol");
+ FALLBACKS.put(TRACES + "key-cert.keys", BASE + "key-cert.keys");
+ FALLBACKS.put(METRICS + "key-cert.keys", BASE + "key-cert.keys");
+ FALLBACKS.put(TRACES + "key-cert.certs", BASE + "key-cert.certs");
+ FALLBACKS.put(METRICS + "key-cert.certs", BASE + "key-cert.certs");
+ FALLBACKS.put(TRACES + "trust-cert.certs", BASE + "trust-cert.certs");
+ FALLBACKS.put(METRICS + "trust-cert.certs", BASE + "trust-cert.certs");
+ FALLBACKS.put(TRACES + "tls-configuration-name", BASE + "tls-configuration-name");
+ FALLBACKS.put(METRICS + "tls-configuration-name", BASE + "tls-configuration-name");
+ FALLBACKS.put(TRACES + "proxy-options.enabled", BASE + "proxy-options.enabled");
+ FALLBACKS.put(METRICS + "proxy-options.enabled", BASE + "proxy-options.enabled");
+ FALLBACKS.put(TRACES + "proxy-options.username", BASE + "proxy-options.username");
+ FALLBACKS.put(METRICS + "proxy-options.username", BASE + "proxy-options.username");
+ FALLBACKS.put(TRACES + "proxy-options.password", BASE + "proxy-options.password");
+ FALLBACKS.put(METRICS + "proxy-options.password", BASE + "proxy-options.password");
+ FALLBACKS.put(TRACES + "proxy-options.port", BASE + "proxy-options.port");
+ FALLBACKS.put(METRICS + "proxy-options.port", BASE + "proxy-options.port");
+ FALLBACKS.put(TRACES + "proxy-options.host", BASE + "proxy-options.host");
+ FALLBACKS.put(METRICS + "proxy-options.host", BASE + "proxy-options.host");
+ }
+
+ @Test
+ void testMapping() {
+ MappingFunction mappingFunction = new MappingFunction();
+ for (String propertyName : FALLBACKS.keySet()) {
+ assertEquals(FALLBACKS.get(propertyName), mappingFunction.apply(propertyName));
+ }
+ }
+
+ @Test
+ void testNotMapping() {
+ MappingFunction mappingFunction = new MappingFunction();
+ assertEquals("something", mappingFunction.apply("something"));
+ }
+}
diff --git a/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/exporter/otlp/HttpClientOptionsConsumerTest.java b/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/exporter/otlp/HttpClientOptionsConsumerTest.java
index 16b7a6c815499..907c467ad6900 100644
--- a/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/exporter/otlp/HttpClientOptionsConsumerTest.java
+++ b/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/exporter/otlp/HttpClientOptionsConsumerTest.java
@@ -56,11 +56,6 @@ public Optional endpoint() {
return Optional.of("http://localhost:4317");
}
- @Override
- public Optional legacyEndpoint() {
- return Optional.empty();
- }
-
@Override
public Optional> headers() {
return Optional.empty();
diff --git a/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpExporterProviderTest.java b/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpExporterProviderTest.java
index 7275aecf8b81b..625baaa74a337 100644
--- a/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpExporterProviderTest.java
+++ b/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpExporterProviderTest.java
@@ -18,67 +18,132 @@
class OtlpExporterProviderTest {
@Test
- public void resolveEndpoint_legacyWins() {
+ public void resolveTraceEndpoint_newWins() {
+ assertEquals("http://localhost:2222/",
+ OTelExporterRecorder.resolveTraceEndpoint(createOtlpExporterRuntimeConfig(
+ "http://localhost:1111/",
+ "http://localhost:2222/")));
+ }
+
+ @Test
+ public void resolveTraceEndpoint_globalWins() {
assertEquals("http://localhost:1111/",
- OTelExporterRecorder.resolveEndpoint(createOtlpExporterRuntimeConfig(
- DEFAULT_GRPC_BASE_URI,
+ OTelExporterRecorder.resolveTraceEndpoint(createOtlpExporterRuntimeConfig(
"http://localhost:1111/",
+ DEFAULT_GRPC_BASE_URI)));
+ }
+
+ @Test
+ public void resolveTraceEndpoint_legacyTraceWins() {
+ assertEquals("http://localhost:2222/",
+ OTelExporterRecorder.resolveTraceEndpoint(createOtlpExporterRuntimeConfig(
+ DEFAULT_GRPC_BASE_URI,
"http://localhost:2222/")));
}
@Test
- public void resolveEndpoint_newWins() {
+ public void resolveTraceEndpoint_legacyGlobalWins() {
+ assertEquals(DEFAULT_GRPC_BASE_URI,
+ OTelExporterRecorder.resolveTraceEndpoint(createOtlpExporterRuntimeConfig(
+ DEFAULT_GRPC_BASE_URI,
+ null)));
+ }
+
+ @Test
+ public void resolveTraceEndpoint_testIsSet() {
+ assertEquals(DEFAULT_GRPC_BASE_URI,
+ OTelExporterRecorder.resolveTraceEndpoint(createOtlpExporterRuntimeConfig(
+ null,
+ null)));
+ }
+
+ @Test
+ public void resolveMetricEndpoint_newWins() {
assertEquals("http://localhost:2222/",
- OTelExporterRecorder.resolveEndpoint(createOtlpExporterRuntimeConfig(
+ OTelExporterRecorder.resolveMetricEndpoint(createOtlpExporterRuntimeConfig(
"http://localhost:1111/",
- DEFAULT_GRPC_BASE_URI,
"http://localhost:2222/")));
}
@Test
- public void resolveEndpoint_globalWins() {
+ public void resolveMetricEndpoint_globalWins() {
assertEquals("http://localhost:1111/",
- OTelExporterRecorder.resolveEndpoint(createOtlpExporterRuntimeConfig(
+ OTelExporterRecorder.resolveMetricEndpoint(createOtlpExporterRuntimeConfig(
"http://localhost:1111/",
- DEFAULT_GRPC_BASE_URI,
DEFAULT_GRPC_BASE_URI)));
}
@Test
- public void resolveEndpoint_legacyTraceWins() {
+ public void resolveMetricEndpoint_legacyTraceWins() {
assertEquals("http://localhost:2222/",
- OTelExporterRecorder.resolveEndpoint(createOtlpExporterRuntimeConfig(
+ OTelExporterRecorder.resolveMetricEndpoint(createOtlpExporterRuntimeConfig(
DEFAULT_GRPC_BASE_URI,
- null,
"http://localhost:2222/")));
}
@Test
- public void resolveEndpoint_legacyGlobalWins() {
+ public void resolveMetricEndpoint_legacyGlobalWins() {
assertEquals(DEFAULT_GRPC_BASE_URI,
- OTelExporterRecorder.resolveEndpoint(createOtlpExporterRuntimeConfig(
+ OTelExporterRecorder.resolveMetricEndpoint(createOtlpExporterRuntimeConfig(
DEFAULT_GRPC_BASE_URI,
- null,
null)));
}
@Test
- public void resolveEndpoint_testIsSet() {
+ public void resolveMetricEndpoint_testIsSet() {
assertEquals(DEFAULT_GRPC_BASE_URI,
- OTelExporterRecorder.resolveEndpoint(createOtlpExporterRuntimeConfig(
- null,
+ OTelExporterRecorder.resolveMetricEndpoint(createOtlpExporterRuntimeConfig(
null,
null)));
}
- private OtlpExporterRuntimeConfig createOtlpExporterRuntimeConfig(String exporterGlobal, String legacyTrace,
- String newTrace) {
+ private OtlpExporterRuntimeConfig createOtlpExporterRuntimeConfig(String exporterGlobal, String newTrace) {
return new OtlpExporterRuntimeConfig() {
@Override
public Optional endpoint() {
return Optional.ofNullable(exporterGlobal);
}
+ @Override
+ public Optional> headers() {
+ return Optional.empty();
+ }
+
+ @Override
+ public Optional compression() {
+ return Optional.empty();
+ }
+
+ @Override
+ public Duration timeout() {
+ return null;
+ }
+
+ @Override
+ public Optional protocol() {
+ return Optional.empty();
+ }
+
+ @Override
+ public KeyCert keyCert() {
+ return null;
+ }
+
+ @Override
+ public TrustCert trustCert() {
+ return null;
+ }
+
+ @Override
+ public Optional tlsConfigurationName() {
+ return Optional.empty();
+ }
+
+ @Override
+ public ProxyConfig proxyOptions() {
+ return null;
+ }
+
@Override
public OtlpExporterTracesConfig traces() {
return new OtlpExporterTracesConfig() {
@@ -87,11 +152,6 @@ public Optional endpoint() {
return Optional.ofNullable(newTrace);
}
- @Override
- public Optional legacyEndpoint() {
- return Optional.ofNullable(legacyTrace);
- }
-
@Override
public Optional> headers() {
return Optional.empty();