From cea1de2b8bf52cfa21a12cbe1f4a64240b51c942 Mon Sep 17 00:00:00 2001 From: Ben Mask Date: Tue, 27 Feb 2024 21:03:33 -0500 Subject: [PATCH] [loadbalancingexporter] Set the default otlp port 4317 in factory and unit test (#31425) **Description:** As described in the otel-collector [issue 9505](https://github.com/open-telemetry/opentelemetry-collector/issues/9505), the otlpexporter does not function correctly if no port is defined. To resolve this, the otlp config validation has been updated to fail fast when the endpoint within an otlp config does not have a port specified. The loadbalancingexporter config has the otlp exporter config as a dependency, however, the loadbalancing exporter does not define a port on the otlpexporter config in two places: - default config from factory - testdata contents This is currently a blocker to the contrib tests for the [PR](https://github.com/open-telemetry/opentelemetry-collector/pull/9632) to resolve issue 9505 Relates to: https://github.com/open-telemetry/opentelemetry-collector/pull/9523 https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/31371 https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/31381 **Link to tracking Issue:** otel-collector-contrib: [issue 31426](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/31426) Arises from otel-collector [issue 9505](https://github.com/open-telemetry/opentelemetry-collector/issues/9505) **Testing:** Used `replace` to test loadbalancingexporter changes pass tests successfully when using the otlpexporter changes from [PR](https://github.com/open-telemetry/opentelemetry-collector/pull/9632) --- exporter/loadbalancingexporter/factory.go | 2 +- .../testdata/test-build-exporter-config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exporter/loadbalancingexporter/factory.go b/exporter/loadbalancingexporter/factory.go index 331ae9a98517..f748ff162c6f 100644 --- a/exporter/loadbalancingexporter/factory.go +++ b/exporter/loadbalancingexporter/factory.go @@ -32,7 +32,7 @@ func NewFactory() exporter.Factory { func createDefaultConfig() component.Config { otlpFactory := otlpexporter.NewFactory() otlpDefaultCfg := otlpFactory.CreateDefaultConfig().(*otlpexporter.Config) - otlpDefaultCfg.Endpoint = "placeholder" + otlpDefaultCfg.Endpoint = "placeholder:4317" return &Config{ Protocol: Protocol{ diff --git a/exporter/loadbalancingexporter/testdata/test-build-exporter-config.yaml b/exporter/loadbalancingexporter/testdata/test-build-exporter-config.yaml index b7e1b4475437..bce0c82f379b 100644 --- a/exporter/loadbalancingexporter/testdata/test-build-exporter-config.yaml +++ b/exporter/loadbalancingexporter/testdata/test-build-exporter-config.yaml @@ -7,7 +7,7 @@ exporters: loadbalancing: protocol: otlp: - endpoint: should-be-replaced + endpoint: should-be-replaced:4317 resolver: static: