Skip to content

Commit b8928ef

Browse files
committed
Merge branch '3.4.x'
Closes gh-44902
2 parents b5f7435 + 7f971d2 commit b8928ef

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ dependencies {
136136
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
137137
testImplementation(testFixtures(project(":spring-boot-project:spring-boot")))
138138
testImplementation("io.micrometer:micrometer-observation-test")
139+
testImplementation("io.opentelemetry:opentelemetry-exporter-common")
139140
testImplementation("io.projectreactor:reactor-test")
140141
testImplementation("io.prometheus:prometheus-metrics-exposition-formats")
141142
testImplementation("io.r2dbc:r2dbc-h2")

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingAutoConfigurationTests.java

+46
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616

1717
package org.springframework.boot.actuate.autoconfigure.tracing.otlp;
1818

19+
import java.util.List;
1920
import java.util.function.Supplier;
2021

2122
import io.opentelemetry.api.metrics.MeterProvider;
23+
import io.opentelemetry.exporter.internal.compression.GzipCompressor;
2224
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter;
2325
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder;
2426
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
2527
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;
2628
import io.opentelemetry.sdk.trace.export.SpanExporter;
2729
import okhttp3.HttpUrl;
30+
import org.assertj.core.api.InstanceOfAssertFactories;
2831
import org.junit.jupiter.api.Test;
2932

3033
import org.springframework.boot.actuate.autoconfigure.tracing.otlp.OtlpTracingConfigurations.ConnectionDetails.PropertiesOtlpTracingConnectionDetails;
@@ -70,6 +73,27 @@ void shouldSupplyBeans() {
7073
.hasSingleBean(SpanExporter.class));
7174
}
7275

76+
@Test
77+
void shouldCustomizeHttpTransportWithProperties() {
78+
this.contextRunner
79+
.withPropertyValues("management.otlp.tracing.endpoint=http://localhost:4317/v1/traces",
80+
"management.otlp.tracing.timeout=10m", "management.otlp.tracing.connect-timeout=20m",
81+
"management.otlp.tracing.compression=GZIP", "management.otlp.tracing.headers.spring=boot")
82+
.run((context) -> {
83+
assertThat(context).hasSingleBean(OtlpHttpSpanExporter.class).hasSingleBean(SpanExporter.class);
84+
OtlpHttpSpanExporter exporter = context.getBean(OtlpHttpSpanExporter.class);
85+
assertThat(exporter).extracting("delegate.httpSender.client")
86+
.hasFieldOrPropertyWithValue("connectTimeoutMillis", 1200000)
87+
.hasFieldOrPropertyWithValue("callTimeoutMillis", 600000);
88+
assertThat(exporter).extracting("delegate.httpSender.compressor").isInstanceOf(GzipCompressor.class);
89+
assertThat(exporter).extracting("delegate.httpSender.headerSupplier")
90+
.asInstanceOf(InstanceOfAssertFactories.type(Supplier.class))
91+
.satisfies((headerSupplier) -> assertThat(headerSupplier.get())
92+
.asInstanceOf(InstanceOfAssertFactories.map(String.class, List.class))
93+
.containsEntry("spring", List.of("boot")));
94+
});
95+
}
96+
7397
@Test
7498
void shouldSupplyBeansIfGrpcTransportIsEnabled() {
7599
this.contextRunner
@@ -79,6 +103,28 @@ void shouldSupplyBeansIfGrpcTransportIsEnabled() {
79103
.hasSingleBean(SpanExporter.class));
80104
}
81105

106+
@Test
107+
void shouldCustomizeGrpcTransportWithProperties() {
108+
this.contextRunner
109+
.withPropertyValues("management.otlp.tracing.endpoint=http://localhost:4317/v1/traces",
110+
"management.otlp.tracing.transport=grpc", "management.otlp.tracing.timeout=10m",
111+
"management.otlp.tracing.connect-timeout=20m", "management.otlp.tracing.compression=GZIP",
112+
"management.otlp.tracing.headers.spring=boot")
113+
.run((context) -> {
114+
assertThat(context).hasSingleBean(OtlpGrpcSpanExporter.class).hasSingleBean(SpanExporter.class);
115+
OtlpGrpcSpanExporter exporter = context.getBean(OtlpGrpcSpanExporter.class);
116+
assertThat(exporter).extracting("delegate.grpcSender.client")
117+
.hasFieldOrPropertyWithValue("connectTimeoutMillis", 1200000)
118+
.hasFieldOrPropertyWithValue("callTimeoutMillis", 600000);
119+
assertThat(exporter).extracting("delegate.grpcSender.compressor").isInstanceOf(GzipCompressor.class);
120+
assertThat(exporter).extracting("delegate.grpcSender.headersSupplier")
121+
.asInstanceOf(InstanceOfAssertFactories.type(Supplier.class))
122+
.satisfies((headerSupplier) -> assertThat(headerSupplier.get())
123+
.asInstanceOf(InstanceOfAssertFactories.map(String.class, List.class))
124+
.containsEntry("spring", List.of("boot")));
125+
});
126+
}
127+
82128
@Test
83129
void shouldNotSupplyBeansIfGlobalTracingIsDisabled() {
84130
this.contextRunner.withPropertyValues("management.tracing.enabled=false")

0 commit comments

Comments
 (0)