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 <luuvansinh555@gmail.com>
This commit is contained in:
parent
5e7d6743a1
commit
ac71d2f5e3
8
apm.go
8
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),
|
||||
|
|
Loading…
Reference in New Issue