feat: support HTTPS protocol for otel (#4159)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2025-06-25 16:35:36 +08:00 committed by GitHub
parent 54e2fa6e26
commit e112f514d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 12 additions and 21 deletions

View File

@ -32,6 +32,9 @@ type TracingConfig struct {
// Endpoint is the endpoint to report tracing log, example: "localhost:4317". // Endpoint is the endpoint to report tracing log, example: "localhost:4317".
Endpoint string `yaml:"endpoint" mapstructure:"endpoint"` Endpoint string `yaml:"endpoint" mapstructure:"endpoint"`
// Path is the path to the tracing server, example: "/v1/traces" if the protocol is "http" or "https".
Path string `yaml:"path" mapstructure:"path"`
// ServiceName is the name of the service for tracing. // ServiceName is the name of the service for tracing.
ServiceName string `yaml:"service-name" mapstructure:"service-name"` ServiceName string `yaml:"service-name" mapstructure:"service-name"`

View File

@ -151,9 +151,13 @@ func initJaegerTracer(ctx context.Context, tracingConfig base.TracingConfig) (fu
) )
switch tracingConfig.Protocol { switch tracingConfig.Protocol {
case "http", "https": case "http":
addr := fmt.Sprintf("%s://%s", tracingConfig.Protocol, tracingConfig.Endpoint) exporter, err = otlptracehttp.New(ctx, otlptracehttp.WithEndpoint(tracingConfig.Endpoint), otlptracehttp.WithURLPath(tracingConfig.Path), otlptracehttp.WithInsecure())
exporter, err = otlptracehttp.New(ctx, otlptracehttp.WithEndpointURL(addr), otlptracehttp.WithInsecure()) if err != nil {
return nil, fmt.Errorf("could not create HTTP trace exporter: %w", err)
}
case "https":
exporter, err = otlptracehttp.New(ctx, otlptracehttp.WithEndpoint(tracingConfig.Endpoint), otlptracehttp.WithURLPath(tracingConfig.Path))
if err != nil { if err != nil {
return nil, fmt.Errorf("could not create HTTP trace exporter: %w", err) return nil, fmt.Errorf("could not create HTTP trace exporter: %w", err)
} }

View File

@ -212,8 +212,3 @@ metrics:
port: 4002 port: 4002
# # ip is the listen ip of the metrics server. # # ip is the listen ip of the metrics server.
# ip: "" # ip: ""
# # tracing is the tracing configuration for dfdaemon.
# tracing:
# # addr is the address to report tracing log.
# addr: ""

View File

@ -164,7 +164,3 @@ console: false
# Listen port for pprof, default is -1 (means disabled). # Listen port for pprof, default is -1 (means disabled).
pprofPort: -1 pprofPort: -1
tracing:
# Jaeger endpoint url, like: http://jaeger.dragonfly.svc:4317.
addr: ''

View File

@ -180,7 +180,3 @@ console: false
# Listen port for pprof, default is -1 (means disabled). # Listen port for pprof, default is -1 (means disabled).
pprofPort: -1 pprofPort: -1
tracing:
# Jaeger endpoint url, like: http://jaeger.dragonfly.svc:4317.
addr: ''

View File

@ -195,8 +195,3 @@ metrics:
port: 4012 port: 4012
# # ip is the listen ip of the metrics server. # # ip is the listen ip of the metrics server.
# ip: "" # ip: ""
# # tracing is the tracing configuration for dfdaemon.
# tracing:
# # addr is the address to report tracing log.
# addr: ""

View File

@ -408,6 +408,7 @@ func New() *Config {
Console: false, Console: false,
PProfPort: -1, PProfPort: -1,
Tracing: base.TracingConfig{ Tracing: base.TracingConfig{
Path: "/v1/traces",
ServiceName: types.ManagerName, ServiceName: types.ManagerName,
}, },
}, },

View File

@ -323,6 +323,7 @@ func New() *Config {
Console: false, Console: false,
PProfPort: -1, PProfPort: -1,
Tracing: base.TracingConfig{ Tracing: base.TracingConfig{
Path: "/v1/traces",
ServiceName: types.SchedulerName, ServiceName: types.SchedulerName,
}, },
}, },