From aea78a9f911c732b98114c85a7e1fd6be15bdddc Mon Sep 17 00:00:00 2001 From: Gaius Date: Wed, 25 Jun 2025 14:50:29 +0800 Subject: [PATCH] feat: support HTTPS protocol for otel Signed-off-by: Gaius --- cmd/dependency/base/option.go | 3 +++ cmd/dependency/dependency.go | 10 +++++++--- deploy/docker-compose/template/client.template.yaml | 5 ----- deploy/docker-compose/template/manager.template.yaml | 4 ---- deploy/docker-compose/template/scheduler.template.yaml | 4 ---- .../docker-compose/template/seed-client.template.yaml | 5 ----- manager/config/config.go | 1 + scheduler/config/config.go | 1 + 8 files changed, 12 insertions(+), 21 deletions(-) diff --git a/cmd/dependency/base/option.go b/cmd/dependency/base/option.go index abb71703a3c..dcb4baf0f1a 100644 --- a/cmd/dependency/base/option.go +++ b/cmd/dependency/base/option.go @@ -32,6 +32,9 @@ type TracingConfig struct { // Endpoint is the endpoint to report tracing log, example: "localhost:4317". 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 string `yaml:"service-name" mapstructure:"service-name"` diff --git a/cmd/dependency/dependency.go b/cmd/dependency/dependency.go index f719ef6fd17..7cd600d23c8 100644 --- a/cmd/dependency/dependency.go +++ b/cmd/dependency/dependency.go @@ -151,9 +151,13 @@ func initJaegerTracer(ctx context.Context, tracingConfig base.TracingConfig) (fu ) switch tracingConfig.Protocol { - case "http", "https": - addr := fmt.Sprintf("%s://%s", tracingConfig.Protocol, tracingConfig.Endpoint) - exporter, err = otlptracehttp.New(ctx, otlptracehttp.WithEndpointURL(addr), otlptracehttp.WithInsecure()) + case "http": + exporter, err = otlptracehttp.New(ctx, otlptracehttp.WithEndpoint(tracingConfig.Endpoint), otlptracehttp.WithURLPath(tracingConfig.Path), 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 { return nil, fmt.Errorf("could not create HTTP trace exporter: %w", err) } diff --git a/deploy/docker-compose/template/client.template.yaml b/deploy/docker-compose/template/client.template.yaml index 4517ceb5186..f0a71db1437 100644 --- a/deploy/docker-compose/template/client.template.yaml +++ b/deploy/docker-compose/template/client.template.yaml @@ -212,8 +212,3 @@ metrics: port: 4002 # # ip is the listen ip of the metrics server. # ip: "" - -# # tracing is the tracing configuration for dfdaemon. -# tracing: -# # addr is the address to report tracing log. -# addr: "" diff --git a/deploy/docker-compose/template/manager.template.yaml b/deploy/docker-compose/template/manager.template.yaml index e54380672bb..dd8bd23dd2a 100644 --- a/deploy/docker-compose/template/manager.template.yaml +++ b/deploy/docker-compose/template/manager.template.yaml @@ -164,7 +164,3 @@ console: false # Listen port for pprof, default is -1 (means disabled). pprofPort: -1 - -tracing: - # Jaeger endpoint url, like: http://jaeger.dragonfly.svc:4317. - addr: '' diff --git a/deploy/docker-compose/template/scheduler.template.yaml b/deploy/docker-compose/template/scheduler.template.yaml index e6b9e3fece7..533c4283b84 100644 --- a/deploy/docker-compose/template/scheduler.template.yaml +++ b/deploy/docker-compose/template/scheduler.template.yaml @@ -180,7 +180,3 @@ console: false # Listen port for pprof, default is -1 (means disabled). pprofPort: -1 - -tracing: - # Jaeger endpoint url, like: http://jaeger.dragonfly.svc:4317. - addr: '' diff --git a/deploy/docker-compose/template/seed-client.template.yaml b/deploy/docker-compose/template/seed-client.template.yaml index d279c0f9384..0946a9eb77a 100644 --- a/deploy/docker-compose/template/seed-client.template.yaml +++ b/deploy/docker-compose/template/seed-client.template.yaml @@ -195,8 +195,3 @@ metrics: port: 4012 # # ip is the listen ip of the metrics server. # ip: "" - -# # tracing is the tracing configuration for dfdaemon. -# tracing: -# # addr is the address to report tracing log. -# addr: "" diff --git a/manager/config/config.go b/manager/config/config.go index 38b8d48b831..a81bec82f8e 100644 --- a/manager/config/config.go +++ b/manager/config/config.go @@ -408,6 +408,7 @@ func New() *Config { Console: false, PProfPort: -1, Tracing: base.TracingConfig{ + Path: "/v1/traces", ServiceName: types.ManagerName, }, }, diff --git a/scheduler/config/config.go b/scheduler/config/config.go index c3f614c3543..87a84e40957 100644 --- a/scheduler/config/config.go +++ b/scheduler/config/config.go @@ -323,6 +323,7 @@ func New() *Config { Console: false, PProfPort: -1, Tracing: base.TracingConfig{ + Path: "/v1/traces", ServiceName: types.SchedulerName, }, },