Skip to content

EndpointUtil.validateEndpoint not handling all valid DNS host names #8745

Description

@jameyg42

Describe the bug
the recent check to validate hostname in EndpointUtils.validateEndpoint() is hitting
https://bugs.openjdk.org/browse/JDK-8188305
that is, URI.getHost() returns null for hostnames that are valid according to modern DNS standards (in my particular case, hostnames w/ a segment that starts with a number).

Steps to reproduce
set otel.exporter.etlp.endpoint to http://otlp.1234-k8s-namespace:4318 (or any other value that triggers the URI.getHost() bug)

What did you expect to see?
normal agent startup

What did you see instead?

io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder - Error encountered during autoconfiguration. Closing partially configured components.
io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException: Unexpected configuration error
        at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.buildImpl(AutoConfiguredOpenTelemetrySdkBuilder.java:510)
        at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.build(AutoConfiguredOpenTelemetrySdkBuilder.java:431)
...
Caused by: java.lang.IllegalArgumentException: Invalid endpoint, must start with http:// or https://: http://otlp-collector.14014-mosaik:4318/v1/metrics
        at io.opentelemetry.exporter.internal.EndpointUtil.validateEndpoint(EndpointUtil.java:34)
        at io.opentelemetry.exporter.otlp.internal.HttpExporterBuilder.setEndpoint(HttpExporterBuilder.java:94)
        at io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder.setEndpoint(OtlpHttpMetricExporterBuilder.java:127)

What version and what artifacts are you using?
edot-java:1.12.0 (otel-instrumentation:2.30.0; sdk: 1.64.0)

possible workaround
in my particular case, because this was a hostname from a k8s namespace that follows a number-prefix naming convention, I was able to get around the java bug simply by using the service FQDN (otlp.1234-k8s-namespace.svc.cluster.local)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions