-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description
Setting
OTEL_EXPORTER_OTLP_ENDPOINT=https://example.com:4317/v1/traces
results in the gRPC exporter failing with
traces export: exporter export timeout: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp: lookup tcp/4317/v1/traces: unknown port"
This seems to be an error with the env variables being parsed here:
opentelemetry-go/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/envconfig.go
Line 117 in 207b0c5
| cfg.Traces.Endpoint = path.Join(u.Host, u.Path) |
That joining of the hostname and path into
endpoint results the HTTP transport try a DNS lookup with example.com:4317/v1/traces which is not a valid hostname.
There is also a misleading example in the documentation here:
https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc#WithEndpointURL
Environment
- OS: Linux
- Architecture: x64
- Go Version: 1.25.5
- opentelemetry-go version: v1.39.0
Steps To Reproduce
Set OTEL_EXPORTER_OTLP_ENDPOINT=https://example.com:4317/v1/traces
Setup code:
res, err := resource.New(
ctx,
resource.WithFromEnv(), // Discover and provide attributes from OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME environment variables.
resource.WithTelemetrySDK(),
resource.WithContainer(),
)
traceExporter, err := otlptracegrpc.New(ctx)
if err != nil {
return nil, fmt.Errorf("otlptracegrpc.New: %v", err)
}
tracerProvider := sdktrace.NewTracerProvider(
sdktrace.WithBatcher(traceExporter),
sdktrace.WithSampler(sdktrace.TraceIDRatioBased(1)),
sdktrace.WithResource(res),
)
otel.SetTracerProvider(tracerProvider)Then force a trace to be created and written.
Expected behavior
Not 100% what is best here. Maybe parsing the URL and rejecting it if there is a ulr.Paht present. That is because gRPC uses the path as part of the service / method discovery and binding.
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.