diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingConfigurations.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingConfigurations.java index 38d4befd5b48..d4c525b01e19 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingConfigurations.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingConfigurations.java @@ -16,14 +16,11 @@ package org.springframework.boot.actuate.autoconfigure.tracing.otlp; -import java.util.Map.Entry; - import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter; import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder; import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter; import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder; -import org.springframework.boot.actuate.autoconfigure.opentelemetry.otlp.Transport; import org.springframework.boot.actuate.autoconfigure.tracing.ConditionalOnEnabledTracing; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -33,7 +30,7 @@ import org.springframework.util.Assert; /** - * Configurations imported by {@link OtlpAutoConfiguration}. + * Configurations imported by {@link OtlpTracingAutoConfiguration}. * * @author Moritz Halbritter * @author EddĂș MelĂ©ndez @@ -46,18 +43,18 @@ static class ConnectionDetails { @Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "management.otlp.tracing", name = "endpoint") - OtlpTracingConnectionDetails otlpTracingConnectionDetails(OtlpProperties properties) { + OtlpTracingConnectionDetails otlpTracingConnectionDetails(OtlpTracingProperties properties) { return new PropertiesOtlpTracingConnectionDetails(properties); } /** - * Adapts {@link OtlpProperties} to {@link OtlpTracingConnectionDetails}. + * Adapts {@link OtlpTracingProperties} to {@link OtlpTracingConnectionDetails}. */ static class PropertiesOtlpTracingConnectionDetails implements OtlpTracingConnectionDetails { - private final OtlpProperties properties; + private final OtlpTracingProperties properties; - PropertiesOtlpTracingConnectionDetails(OtlpProperties properties) { + PropertiesOtlpTracingConnectionDetails(OtlpTracingProperties properties) { this.properties = properties; } @@ -82,29 +79,27 @@ static class Exporters { @Bean @ConditionalOnProperty(prefix = "management.otlp.tracing", name = "transport", havingValue = "http", matchIfMissing = true) - OtlpHttpSpanExporter otlpHttpSpanExporter(OtlpProperties properties, + OtlpHttpSpanExporter otlpHttpSpanExporter(OtlpTracingProperties properties, OtlpTracingConnectionDetails connectionDetails) { OtlpHttpSpanExporterBuilder builder = OtlpHttpSpanExporter.builder() .setEndpoint(connectionDetails.getUrl(Transport.HTTP)) .setTimeout(properties.getTimeout()) + .setConnectTimeout(properties.getConnectTimeout()) .setCompression(properties.getCompression().name().toLowerCase()); - for (Entry header : properties.getHeaders().entrySet()) { - builder.addHeader(header.getKey(), header.getValue()); - } + properties.getHeaders().forEach(builder::addHeader); return builder.build(); } @Bean @ConditionalOnProperty(prefix = "management.otlp.tracing", name = "transport", havingValue = "grpc") - OtlpGrpcSpanExporter otlpGrpcSpanExporter(OtlpProperties properties, + OtlpGrpcSpanExporter otlpGrpcSpanExporter(OtlpTracingProperties properties, OtlpTracingConnectionDetails connectionDetails) { OtlpGrpcSpanExporterBuilder builder = OtlpGrpcSpanExporter.builder() .setEndpoint(connectionDetails.getUrl(Transport.GRPC)) .setTimeout(properties.getTimeout()) + .setConnectTimeout(properties.getConnectTimeout()) .setCompression(properties.getCompression().name().toLowerCase()); - for (Entry header : properties.getHeaders().entrySet()) { - builder.addHeader(header.getKey(), header.getValue()); - } + properties.getHeaders().forEach(builder::addHeader); return builder.build(); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingConnectionDetails.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingConnectionDetails.java index 2b556c60d70f..bb50e4e7bc86 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingConnectionDetails.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingConnectionDetails.java @@ -16,7 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.tracing.otlp; -import org.springframework.boot.actuate.autoconfigure.opentelemetry.otlp.Transport; import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails; /** diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingProperties.java similarity index 84% rename from spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpProperties.java rename to spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingProperties.java index fe1ae7836af5..6ebbdb2cf7b6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingProperties.java @@ -20,8 +20,6 @@ import java.util.HashMap; import java.util.Map; -import org.springframework.boot.actuate.autoconfigure.opentelemetry.otlp.Compression; -import org.springframework.boot.actuate.autoconfigure.opentelemetry.otlp.Transport; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -31,7 +29,7 @@ * @since 3.1.0 */ @ConfigurationProperties("management.otlp.tracing") -public class OtlpProperties { +public class OtlpTracingProperties { /** * URL to the OTel collector's HTTP API. @@ -46,6 +44,11 @@ public class OtlpProperties { */ private Duration timeout = Duration.ofSeconds(10); + /** + * Connect timeout for the OTel collector connection. + */ + private Duration connectTimeout = Duration.ofSeconds(10); + /** * Transport used to send the spans. */ @@ -77,6 +80,14 @@ public void setTimeout(Duration timeout) { this.timeout = timeout; } + public Duration getConnectTimeout() { + return this.connectTimeout; + } + + public void setConnectTimeout(Duration connectTimeout) { + this.connectTimeout = connectTimeout; + } + public Transport getTransport() { return this.transport; } @@ -101,4 +112,18 @@ public void setHeaders(Map headers) { this.headers = headers; } + public enum Compression { + + /** + * Gzip compression. + */ + GZIP, + + /** + * No compression. + */ + NONE + + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/otlp/Compression.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/Transport.java similarity index 78% rename from spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/otlp/Compression.java rename to spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/Transport.java index 15183900d4b0..470a11e26f98 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/otlp/Compression.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/Transport.java @@ -14,24 +14,24 @@ * limitations under the License. */ -package org.springframework.boot.actuate.autoconfigure.opentelemetry.otlp; +package org.springframework.boot.actuate.autoconfigure.tracing.otlp; /** - * Algorithm used to compress OTLP data. + * Transport used to send OTLP data. * * @author Moritz Halbritter * @since 3.4.0 */ -public enum Compression { +public enum Transport { /** - * Gzip compression. + * HTTP transport. */ - GZIP, + HTTP, /** - * No compression. + * gRPC transport. */ - NONE + GRPC } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/package-info.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/package-info.java index b021e3da9fca..b0e7790ac838 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/package-info.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/package-info.java @@ -15,6 +15,6 @@ */ /** - * Auto-configuration for tracing with OTLP. + * Auto-configuration for exporting traces with OTLP. */ package org.springframework.boot.actuate.autoconfigure.tracing.otlp;