From 0df7ac4e807e31b02404cd8ce410bda41d035f15 Mon Sep 17 00:00:00 2001 From: champly Date: Wed, 12 May 2021 10:36:58 +0800 Subject: [PATCH 1/3] fix jaeger deprecated config --- .../commands/root/tracing_register_jaeger.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go b/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go index f23b56f34..3241d36dc 100644 --- a/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go +++ b/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go @@ -18,6 +18,7 @@ package root import ( "errors" + "fmt" "os" "contrib.go.opencensus.io/exporter/jaeger" @@ -31,17 +32,21 @@ func init() { // NewJaegerExporter creates a new opencensus tracing exporter. func NewJaegerExporter(opts TracingExporterOptions) (trace.Exporter, error) { jOpts := jaeger.Options{ - Endpoint: os.Getenv("JAEGER_ENDPOINT"), - AgentEndpoint: os.Getenv("JAEGER_AGENT_ENDPOINT"), - Username: os.Getenv("JAEGER_USER"), - Password: os.Getenv("JAEGER_PASSWORD"), + Endpoint: os.Getenv("JAEGER_ENDPOINT"), // deprecated + CollectorEndpoint: os.Getenv("JAEGER_COLLECTOR_ENDPOINT"), + AgentEndpoint: os.Getenv("JAEGER_AGENT_ENDPOINT"), + Username: os.Getenv("JAEGER_USER"), + Password: os.Getenv("JAEGER_PASSWORD"), Process: jaeger.Process{ ServiceName: opts.ServiceName, }, } - if jOpts.Endpoint == "" && jOpts.AgentEndpoint == "" { // nolint:staticcheck - return nil, errors.New("Must specify either JAEGER_ENDPOINT or JAEGER_AGENT_ENDPOINT") + if jOpts.Endpoint != "" && jOpts.CollectorEndpoint == "" { + jOpts.CollectorEndpoint = fmt.Sprintf("%s/api/traces", jOpts.Endpoint) + } + if jOpts.CollectorEndpoint == "" && jOpts.AgentEndpoint == "" { // nolint:staticcheck + return nil, errors.New("Must specify either JAEGER_COLLECTOR_ENDPOINT or JAEGER_AGENT_ENDPOINT") } for k, v := range opts.Tags { From 66fc9d476f65b60bdcceeb65df7503dc0bd8feab Mon Sep 17 00:00:00 2001 From: champly Date: Wed, 19 May 2021 09:13:28 +0800 Subject: [PATCH 2/3] fix staticcheck --- .../internal/commands/root/tracing_register_jaeger.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go b/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go index 3241d36dc..92aa5fb09 100644 --- a/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go +++ b/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go @@ -42,10 +42,10 @@ func NewJaegerExporter(opts TracingExporterOptions) (trace.Exporter, error) { }, } - if jOpts.Endpoint != "" && jOpts.CollectorEndpoint == "" { + if jOpts.Endpoint != "" && jOpts.CollectorEndpoint == "" { // nolintlint:staticcheck jOpts.CollectorEndpoint = fmt.Sprintf("%s/api/traces", jOpts.Endpoint) } - if jOpts.CollectorEndpoint == "" && jOpts.AgentEndpoint == "" { // nolint:staticcheck + if jOpts.CollectorEndpoint == "" && jOpts.AgentEndpoint == "" { // nolintlint:staticcheck return nil, errors.New("Must specify either JAEGER_COLLECTOR_ENDPOINT or JAEGER_AGENT_ENDPOINT") } From 50f1346977f4d31986f85a3cc6100b2e2476a2a0 Mon Sep 17 00:00:00 2001 From: champly Date: Wed, 19 May 2021 09:17:06 +0800 Subject: [PATCH 3/3] fix staticcheck --- .../internal/commands/root/tracing_register_jaeger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go b/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go index 92aa5fb09..73c9e2e86 100644 --- a/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go +++ b/cmd/virtual-kubelet/internal/commands/root/tracing_register_jaeger.go @@ -43,7 +43,7 @@ func NewJaegerExporter(opts TracingExporterOptions) (trace.Exporter, error) { } if jOpts.Endpoint != "" && jOpts.CollectorEndpoint == "" { // nolintlint:staticcheck - jOpts.CollectorEndpoint = fmt.Sprintf("%s/api/traces", jOpts.Endpoint) + jOpts.CollectorEndpoint = fmt.Sprintf("%s/api/traces", jOpts.Endpoint) // nolintlint:staticcheck } if jOpts.CollectorEndpoint == "" && jOpts.AgentEndpoint == "" { // nolintlint:staticcheck return nil, errors.New("Must specify either JAEGER_COLLECTOR_ENDPOINT or JAEGER_AGENT_ENDPOINT")