fix issue with endpoint configuration

This commit is contained in:
jonny rhea 2026-01-01 13:43:50 -06:00 committed by Felix Lange
parent d9c9243251
commit 135f0fbfb1

View file

@ -60,12 +60,10 @@ func SetupOTEL(ctx *cli.Context) (*otelService, error) {
if !ctx.Bool(OTELEnabledFlag.Name) {
return nil, nil
}
endpoint := ctx.String(OTELEndpointFlag.Name)
if endpoint == "" {
return nil, nil
}
serviceName := ctx.String(OTELServiceNameFlag.Name)
setupCtx := ctx.Context
if setupCtx == nil {
@ -82,11 +80,14 @@ func SetupOTEL(ctx *cli.Context) (*otelService, error) {
switch u.Scheme {
case "http", "https":
opts := []otlptracehttp.Option{
otlptracehttp.WithEndpoint(endpoint),
otlptracehttp.WithEndpoint(u.Host),
}
if u.Scheme == "http" {
opts = append(opts, otlptracehttp.WithInsecure())
}
if u.Path != "" && u.Path != "/" {
opts = append(opts, otlptracehttp.WithURLPath(u.Path))
}
exporter, err = otlptracehttp.New(setupCtx, opts...)
default:
return nil, fmt.Errorf("unsupported otel url scheme: %s", u.Scheme)