From ac71d2f5e3289bc0680fadb7cc442049dd961f70 Mon Sep 17 00:00:00 2001 From: Sinh Date: Tue, 9 Jul 2024 11:07:53 +0700 Subject: [PATCH] feat: refactor authorization handling across files - Remove the unused import for `encoding/base64` - Update the authorization header handling in the `InitOtelAPM` function Signed-off-by: Sinh --- apm.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apm.go b/apm.go index 0e6fa53..b1fc7c7 100644 --- a/apm.go +++ b/apm.go @@ -2,7 +2,6 @@ package apm import ( "context" - "encoding/base64" "github.com/labstack/echo/v4" "go.mongodb.org/mongo-driver/event" @@ -29,8 +28,7 @@ var ( type OtelConfig struct { Endpoint string Path string - AuthUser string - AuthPwd string + AuthHeader string ServiceName string ServiceVersion string Env string @@ -45,8 +43,8 @@ func InitOtelAPM(config OtelConfig) error { otlptracehttp.NewClient() authHeaders := map[string]string{} - if config.AuthUser != "" && config.AuthPwd != "" { - authHeaders["Authorization"] = "Basic " + base64.StdEncoding.EncodeToString([]byte(config.AuthUser+":"+config.AuthPwd)) + if config.AuthHeader != "" { + authHeaders["Authorization"] = config.AuthHeader } otlpHTTPExporter, err := otlptracehttp.New(context.Background(), otlptracehttp.WithEndpoint(config.Endpoint),