Polish "Add service connection from OpenTelemetry Collector"
See gh-35082
This commit is contained in:
@@ -16,40 +16,40 @@
|
||||
|
||||
package org.springframework.boot.docker.compose.service.connection.otlp;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.otlp.OtlpConnectionDetails;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.otlp.OtlpMetricsConnectionDetails;
|
||||
import org.springframework.boot.docker.compose.core.RunningService;
|
||||
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
|
||||
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionSource;
|
||||
|
||||
/**
|
||||
* {@link DockerComposeConnectionDetailsFactory} to create {@link OtlpConnectionDetails}
|
||||
* for a {@code otlp} service.
|
||||
* {@link DockerComposeConnectionDetailsFactory} to create
|
||||
* {@link OtlpMetricsConnectionDetails} for a {@code OTLP} service.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
*/
|
||||
class OpenTelemetryDockerComposeConnectionDetailsFactory
|
||||
extends DockerComposeConnectionDetailsFactory<OtlpConnectionDetails> {
|
||||
class OpenTelemetryMetricsDockerComposeConnectionDetailsFactory
|
||||
extends DockerComposeConnectionDetailsFactory<OtlpMetricsConnectionDetails> {
|
||||
|
||||
private static final int OTLP_PORT = 4318;
|
||||
|
||||
OpenTelemetryDockerComposeConnectionDetailsFactory() {
|
||||
OpenTelemetryMetricsDockerComposeConnectionDetailsFactory() {
|
||||
super("otel/opentelemetry-collector-contrib",
|
||||
"org.springframework.boot.actuate.autoconfigure.metrics.export.otlp.OtlpMetricsExportAutoConfiguration");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OtlpConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) {
|
||||
return new OpenTelemetryContainerConnectionDetails(source.getRunningService());
|
||||
protected OtlpMetricsConnectionDetails getDockerComposeConnectionDetails(DockerComposeConnectionSource source) {
|
||||
return new OpenTelemetryContainerMetricsConnectionDetails(source.getRunningService());
|
||||
}
|
||||
|
||||
private static final class OpenTelemetryContainerConnectionDetails extends DockerComposeConnectionDetails
|
||||
implements OtlpConnectionDetails {
|
||||
private static final class OpenTelemetryContainerMetricsConnectionDetails extends DockerComposeConnectionDetails
|
||||
implements OtlpMetricsConnectionDetails {
|
||||
|
||||
private final String host;
|
||||
|
||||
private final int port;
|
||||
|
||||
private OpenTelemetryContainerConnectionDetails(RunningService source) {
|
||||
private OpenTelemetryContainerMetricsConnectionDetails(RunningService source) {
|
||||
super(source);
|
||||
this.host = source.host();
|
||||
this.port = source.ports().get(OTLP_PORT);
|
||||
@@ -57,7 +57,7 @@ class OpenTelemetryDockerComposeConnectionDetailsFactory
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return "http://" + this.host + ":" + this.port + "/v1/metrics";
|
||||
return "http://%s:%d/v1/metrics".formatted(this.host, this.port);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import org.springframework.boot.docker.compose.service.connection.DockerComposeC
|
||||
|
||||
/**
|
||||
* {@link DockerComposeConnectionDetailsFactory} to create
|
||||
* {@link OtlpTracingConnectionDetails} for a {@code otlp} service.
|
||||
* {@link OtlpTracingConnectionDetails} for a {@code OTLP} service.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
*/
|
||||
@@ -57,7 +57,7 @@ class OpenTelemetryTracingDockerComposeConnectionDetailsFactory
|
||||
|
||||
@Override
|
||||
public String getEndpoint() {
|
||||
return "http://" + this.host + ":" + this.port + "/v1/traces";
|
||||
return "http://%s:%d/v1/traces".formatted(this.host, this.port);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ org.springframework.boot.docker.compose.service.connection.mysql.MySqlJdbcDocker
|
||||
org.springframework.boot.docker.compose.service.connection.mysql.MySqlR2dbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.oracle.OracleJdbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.oracle.OracleR2dbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.otlp.OpenTelemetryDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.otlp.OpenTelemetryMetricsDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.otlp.OpenTelemetryTracingDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.postgres.PostgresJdbcDockerComposeConnectionDetailsFactory,\
|
||||
org.springframework.boot.docker.compose.service.connection.postgres.PostgresR2dbcDockerComposeConnectionDetailsFactory,\
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docker.compose.service.connection.otlp;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.otlp.OtlpMetricsConnectionDetails;
|
||||
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for
|
||||
* {@link OpenTelemetryMetricsDockerComposeConnectionDetailsFactory}.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
*/
|
||||
public class OpenTelemetryMetricsDockerComposeConnectionDetailsFactoryIntegrationTests
|
||||
extends AbstractDockerComposeIntegrationTests {
|
||||
|
||||
OpenTelemetryMetricsDockerComposeConnectionDetailsFactoryIntegrationTests() {
|
||||
super("otlp-compose.yaml", DockerImageNames.opentelemetry());
|
||||
}
|
||||
|
||||
@Test
|
||||
void runCreatesConnectionDetails() {
|
||||
OtlpMetricsConnectionDetails connectionDetails = run(OtlpMetricsConnectionDetails.class);
|
||||
assertThat(connectionDetails.getUrl()).startsWith("http://").endsWith("/v1/metrics");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@ package org.springframework.boot.docker.compose.service.connection.otlp;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.otlp.OtlpConnectionDetails;
|
||||
import org.springframework.boot.actuate.autoconfigure.tracing.otlp.OtlpTracingConnectionDetails;
|
||||
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
|
||||
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
@@ -26,25 +25,20 @@ import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link OpenTelemetryDockerComposeConnectionDetailsFactory}.
|
||||
* Integration tests for
|
||||
* {@link OpenTelemetryTracingDockerComposeConnectionDetailsFactory}.
|
||||
*
|
||||
* @author Eddú Meléndez
|
||||
*/
|
||||
public class OpenTelemetryDockerComposeConnectionDetailsFactoryIntegrationTests
|
||||
public class OpenTelemetryTracingDockerComposeConnectionDetailsFactoryIntegrationTests
|
||||
extends AbstractDockerComposeIntegrationTests {
|
||||
|
||||
OpenTelemetryDockerComposeConnectionDetailsFactoryIntegrationTests() {
|
||||
OpenTelemetryTracingDockerComposeConnectionDetailsFactoryIntegrationTests() {
|
||||
super("otlp-compose.yaml", DockerImageNames.opentelemetry());
|
||||
}
|
||||
|
||||
@Test
|
||||
void runCreatesConnectionDetails() {
|
||||
OtlpConnectionDetails connectionDetails = run(OtlpConnectionDetails.class);
|
||||
assertThat(connectionDetails.getUrl()).startsWith("http://").endsWith("/v1/metrics");
|
||||
}
|
||||
|
||||
@Test
|
||||
void runCreatesTracingConnectionDetails() {
|
||||
OtlpTracingConnectionDetails connectionDetails = run(OtlpTracingConnectionDetails.class);
|
||||
assertThat(connectionDetails.getEndpoint()).startsWith("http://").endsWith("/v1/traces");
|
||||
}
|
||||
Reference in New Issue
Block a user