Support Otlp Tracing's GRPC port from service connections
Otlp Tracing's exporter is configured using Transport. Current support for service connections read the mapped port for HTTP transport 4318. This commits adds support to read port for GRPC transport 4317. See gh-41333
This commit is contained in:
committed by
Moritz Halbritter
parent
f6505f7a18
commit
7baa553760
@@ -43,13 +43,16 @@ class OpenTelemetryTracingContainerConnectionDetailsFactoryIntegrationTests {
|
||||
|
||||
@Container
|
||||
@ServiceConnection
|
||||
static final GenericContainer<?> container = TestImage.OPENTELEMETRY.genericContainer().withExposedPorts(4318);
|
||||
static final GenericContainer<?> container = TestImage.OPENTELEMETRY.genericContainer()
|
||||
.withExposedPorts(4317, 4318);
|
||||
|
||||
@Autowired
|
||||
private OtlpTracingConnectionDetails connectionDetails;
|
||||
|
||||
@Test
|
||||
void connectionCanBeMadeToOpenTelemetryContainer() {
|
||||
assertThat(this.connectionDetails.getGrpcEndpoint())
|
||||
.isEqualTo("http://" + container.getHost() + ":" + container.getMappedPort(4317) + "/v1/traces");
|
||||
assertThat(this.connectionDetails.getUrl())
|
||||
.isEqualTo("http://" + container.getHost() + ":" + container.getMappedPort(4318) + "/v1/traces");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2024 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.
|
||||
@@ -35,6 +35,10 @@ import org.springframework.boot.testcontainers.service.connection.ServiceConnect
|
||||
class OpenTelemetryTracingContainerConnectionDetailsFactory
|
||||
extends ContainerConnectionDetailsFactory<Container<?>, OtlpTracingConnectionDetails> {
|
||||
|
||||
private static final int OTLP_GRPC_PORT = 4317;
|
||||
|
||||
private static final int OTLP_HTTP_PORT = 4318;
|
||||
|
||||
OpenTelemetryTracingContainerConnectionDetailsFactory() {
|
||||
super("otel/opentelemetry-collector-contrib",
|
||||
"org.springframework.boot.actuate.autoconfigure.tracing.otlp.OtlpAutoConfiguration");
|
||||
@@ -55,7 +59,14 @@ class OpenTelemetryTracingContainerConnectionDetailsFactory
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return "http://%s:%d/v1/traces".formatted(getContainer().getHost(), getContainer().getMappedPort(4318));
|
||||
return "http://%s:%d/v1/traces".formatted(getContainer().getHost(),
|
||||
getContainer().getMappedPort(OTLP_HTTP_PORT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrpcEndpoint() {
|
||||
return "http://%s:%d/v1/traces".formatted(getContainer().getHost(),
|
||||
getContainer().getMappedPort(OTLP_GRPC_PORT));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user