Remove default value for OtlpMetricsProperties.url
See gh-44493 Signed-off-by: Johnny Lim <izeye@naver.com>
This commit is contained in:
parent
ccfc1aeedc
commit
75f72b6ee7
|
@ -174,6 +174,7 @@ dependencies {
|
|||
testImplementation("org.springframework.restdocs:spring-restdocs-webtestclient")
|
||||
testImplementation("org.springframework.security:spring-security-test")
|
||||
testImplementation("org.yaml:snakeyaml")
|
||||
testImplementation("uk.org.webcompere:system-stubs-jupiter:2.1.7")
|
||||
|
||||
testRuntimeOnly("jakarta.management.j2ee:jakarta.management.j2ee-api")
|
||||
testRuntimeOnly("jakarta.transaction:jakarta.transaction-api")
|
||||
|
|
|
@ -39,7 +39,7 @@ public class OtlpMetricsProperties extends StepRegistryProperties {
|
|||
/**
|
||||
* URI of the OTLP server.
|
||||
*/
|
||||
private String url = "http://localhost:4318/v1/metrics";
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Aggregation temporality of sums. It defines the way additive values are expressed.
|
||||
|
|
|
@ -23,6 +23,7 @@ import io.micrometer.registry.otlp.AggregationTemporality;
|
|||
import io.micrometer.registry.otlp.HistogramFlavor;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import uk.org.webcompere.systemstubs.SystemStubs;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.otlp.OtlpMetricsExportAutoConfiguration.PropertiesOtlpMetricsConnectionDetails;
|
||||
import org.springframework.boot.actuate.autoconfigure.opentelemetry.OpenTelemetryProperties;
|
||||
|
@ -54,6 +55,23 @@ class OtlpMetricsPropertiesConfigAdapterTests {
|
|||
this.connectionDetails = new PropertiesOtlpMetricsConnectionDetails(this.properties);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenPropertiesUrlIsNotSetAdapterUrlReturnsDefault() {
|
||||
assertThat(createAdapter().url()).isEqualTo("http://localhost:4318/v1/metrics");
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenPropertiesUrlIsNotSetAndOtelExporterOtlpEndpointIsSetAdapterUrlUsesIt() throws Exception {
|
||||
SystemStubs.withEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT", "https://my-endpoint")
|
||||
.execute(() -> assertThat(createAdapter().url()).isEqualTo("https://my-endpoint/v1/metrics"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenPropertiesUrlIsNotSetAndOtelExporterOtlpMetricsEndpointIsSetAdapterUrlUsesIt() throws Exception {
|
||||
SystemStubs.withEnvironmentVariable("OTEL_EXPORTER_OTLP_METRICS_ENDPOINT", "https://my-endpoint")
|
||||
.execute(() -> assertThat(createAdapter().url()).isEqualTo("https://my-endpoint/v1/metrics"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenPropertiesUrlIsSetAdapterUrlReturnsIt() {
|
||||
this.properties.setUrl("http://another-url:4318/v1/metrics");
|
||||
|
|
|
@ -35,7 +35,6 @@ class OtlpMetricsPropertiesTests extends StepRegistryPropertiesTests {
|
|||
OtlpMetricsProperties properties = new OtlpMetricsProperties();
|
||||
OtlpConfig config = OtlpConfig.DEFAULT;
|
||||
assertStepRegistryDefaultValues(properties, config);
|
||||
assertThat(properties.getUrl()).isEqualTo(config.url());
|
||||
assertThat(properties.getAggregationTemporality()).isSameAs(config.aggregationTemporality());
|
||||
assertThat(properties.getHistogramFlavor()).isSameAs(config.histogramFlavor());
|
||||
assertThat(properties.getMaxScale()).isEqualTo(config.maxScale());
|
||||
|
|
Loading…
Reference in New Issue