From e8c1240a2b74e17156a31330bea6ebd9e71df167 Mon Sep 17 00:00:00 2001 From: mayankpande88 Date: Tue, 14 Jul 2026 22:46:22 +0530 Subject: [PATCH] fix(otel): don't combine WithTLSClientConfig with WithInsecure otel v1.43+ rejects a TLS client config on insecure HTTP endpoints: F tracing.go:77] insecure HTTP endpoint cannot use TLS client configuration Since the otel group bump, the agent fatals at startup whenever TRACES_ENDPOINT is plain HTTP (e.g. the in-cluster otel collector). Apply WithTLSClientConfig only for https endpoints, in both the traces and logs exporters. --- logs/otel.go | 3 ++- tracing/tracing.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/logs/otel.go b/logs/otel.go index 79213a2..80abce1 100644 --- a/logs/otel.go +++ b/logs/otel.go @@ -37,10 +37,11 @@ func Init(machineId, hostname, version string) { otlplogshttp.WithEndpoint(endpointUrl.Host), otlplogshttp.WithURLPath(path), otlplogshttp.WithHeaders(common.AuthHeaders()), - otlplogshttp.WithTLSClientConfig(&tls.Config{InsecureSkipVerify: *flags.InsecureSkipVerify}), } if endpointUrl.Scheme != "https" { opts = append(opts, otlplogshttp.WithInsecure()) + } else { + opts = append(opts, otlplogshttp.WithTLSClientConfig(&tls.Config{InsecureSkipVerify: *flags.InsecureSkipVerify})) } client := otlplogshttp.NewClient(opts...) exporter, _ := otlplogs.NewExporter(context.Background(), otlplogs.WithClient(client)) diff --git a/tracing/tracing.go b/tracing/tracing.go index ef59952..f95237a 100644 --- a/tracing/tracing.go +++ b/tracing/tracing.go @@ -66,10 +66,11 @@ func Init(machineId, hostname, version string) { otlptracehttp.WithEndpoint(endpointUrl.Host), otlptracehttp.WithURLPath(path), otlptracehttp.WithHeaders(common.AuthHeaders()), - otlptracehttp.WithTLSClientConfig(&tls.Config{InsecureSkipVerify: *flags.InsecureSkipVerify}), } if endpointUrl.Scheme != "https" { opts = append(opts, otlptracehttp.WithInsecure()) + } else { + opts = append(opts, otlptracehttp.WithTLSClientConfig(&tls.Config{InsecureSkipVerify: *flags.InsecureSkipVerify})) } client := otlptracehttp.NewClient(opts...) exporter, err := otlptrace.New(context.Background(), client)