From 3dd6372602d3d79ffd14f8005934c81733956e07 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Thu, 14 Sep 2023 11:10:19 +0200 Subject: [PATCH] Polish "Add service connection from OpenTelemetry Collector" See gh-35082 --- .../autoconfigure/tracing/otlp/OtlpTracingConfigurations.java | 4 ++-- .../tracing/otlp/OtlpTracingConnectionDetails.java | 2 +- ...TelemetryTracingDockerComposeConnectionDetailsFactory.java | 2 +- ...DockerComposeConnectionDetailsFactoryIntegrationTests.java | 2 +- .../otlp/OpenTelemetryTracingConnectionDetailsFactory.java | 2 +- ...emetryTracingConnectionDetailsFactoryIntegrationTests.java | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) 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 6fc5f21fd1..eb136aac21 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 @@ -60,7 +60,7 @@ final class OtlpTracingConfigurations { } @Override - public String getEndpoint() { + public String getUrl() { return this.properties.getEndpoint(); } @@ -79,7 +79,7 @@ final class OtlpTracingConfigurations { OtlpHttpSpanExporter otlpHttpSpanExporter(OtlpProperties properties, OtlpTracingConnectionDetails connectionDetails) { OtlpHttpSpanExporterBuilder builder = OtlpHttpSpanExporter.builder() - .setEndpoint(connectionDetails.getEndpoint()) + .setEndpoint(connectionDetails.getUrl()) .setTimeout(properties.getTimeout()) .setCompression(properties.getCompression().name().toLowerCase()); for (Entry header : properties.getHeaders().entrySet()) { 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 e5c8e5b375..fb73b615bb 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 @@ -30,6 +30,6 @@ public interface OtlpTracingConnectionDetails extends ConnectionDetails { * Address to where metrics will be published. * @return the address to where metrics will be published */ - String getEndpoint(); + String getUrl(); } diff --git a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/otlp/OpenTelemetryTracingDockerComposeConnectionDetailsFactory.java b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/otlp/OpenTelemetryTracingDockerComposeConnectionDetailsFactory.java index 2a1254017f..359f4df193 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/otlp/OpenTelemetryTracingDockerComposeConnectionDetailsFactory.java +++ b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/otlp/OpenTelemetryTracingDockerComposeConnectionDetailsFactory.java @@ -56,7 +56,7 @@ class OpenTelemetryTracingDockerComposeConnectionDetailsFactory } @Override - public String getEndpoint() { + public String getUrl() { return "http://%s:%d/v1/traces".formatted(this.host, this.port); } diff --git a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/otlp/OpenTelemetryTracingDockerComposeConnectionDetailsFactoryIntegrationTests.java b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/otlp/OpenTelemetryTracingDockerComposeConnectionDetailsFactoryIntegrationTests.java index 5eee38a1e4..7afae26469 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/otlp/OpenTelemetryTracingDockerComposeConnectionDetailsFactoryIntegrationTests.java +++ b/spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/otlp/OpenTelemetryTracingDockerComposeConnectionDetailsFactoryIntegrationTests.java @@ -40,7 +40,7 @@ public class OpenTelemetryTracingDockerComposeConnectionDetailsFactoryIntegratio @Test void runCreatesConnectionDetails() { OtlpTracingConnectionDetails connectionDetails = run(OtlpTracingConnectionDetails.class); - assertThat(connectionDetails.getEndpoint()).startsWith("http://").endsWith("/v1/traces"); + assertThat(connectionDetails.getUrl()).startsWith("http://").endsWith("/v1/traces"); } } diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryTracingConnectionDetailsFactory.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryTracingConnectionDetailsFactory.java index 0a6d9f6369..4f4a394cd3 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryTracingConnectionDetailsFactory.java +++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryTracingConnectionDetailsFactory.java @@ -54,7 +54,7 @@ class OpenTelemetryTracingConnectionDetailsFactory } @Override - public String getEndpoint() { + public String getUrl() { return "http://%s:%d/v1/traces".formatted(getContainer().getHost(), getContainer().getMappedPort(4318)); } diff --git a/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryTracingConnectionDetailsFactoryIntegrationTests.java b/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryTracingConnectionDetailsFactoryIntegrationTests.java index f752c3b18e..4367967b5a 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryTracingConnectionDetailsFactoryIntegrationTests.java +++ b/spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/service/connection/otlp/OpenTelemetryTracingConnectionDetailsFactoryIntegrationTests.java @@ -51,7 +51,7 @@ class OpenTelemetryTracingConnectionDetailsFactoryIntegrationTests { @Test void connectionCanBeMadeToOpenTelemetryContainer() { - assertThat(this.connectionDetails.getEndpoint()) + assertThat(this.connectionDetails.getUrl()) .isEqualTo("http://" + container.getHost() + ":" + container.getMappedPort(4318) + "/v1/traces"); }