From 3211524185df3da8aba70d8ca621e18f2850af3e Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Sun, 3 May 2026 15:15:21 -0700 Subject: [PATCH] tracing: allow basic auth --- pkg/cmd/tracing.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/tracing.go b/pkg/cmd/tracing.go index d085836f..a7393318 100644 --- a/pkg/cmd/tracing.go +++ b/pkg/cmd/tracing.go @@ -2,6 +2,8 @@ package cmd import ( "context" + "encoding/base64" + "net/url" "time" "go.opentelemetry.io/otel" @@ -25,7 +27,23 @@ func startTelemetry(ctx context.Context, endpoint string) error { } func newTracerProvider(ctx context.Context, endpoint string) (*trace.TracerProvider, error) { - exp, err := otlptracehttp.New(ctx, otlptracehttp.WithEndpointURL(endpoint)) + parsedURL, err := url.Parse(endpoint) + if err != nil { + return nil, err + } + + opts := []otlptracehttp.Option{otlptracehttp.WithEndpointURL(endpoint)} + + if parsedURL.User != nil { + username := parsedURL.User.Username() + password, _ := parsedURL.User.Password() + encoded := base64.StdEncoding.EncodeToString([]byte(username + ":" + password)) + opts = append(opts, otlptracehttp.WithHeaders(map[string]string{ + "Authorization": "Basic " + encoded, + })) + } + + exp, err := otlptracehttp.New(ctx, opts...) if err != nil { return nil, err } -- 2.51.2