fix(telemetry): tracer did not initialize
All checks were successful
Gitea Build Check / Build (pull_request) Successful in 2m25s

fixed a bug where the OtterSpacesSDK Crashes if no tracer was initialized
This commit is contained in:
SoXX 2024-08-29 10:44:40 +02:00
parent 975e084b16
commit 150313f7d7

View File

@ -13,7 +13,6 @@ import (
"go.opentelemetry.io/contrib/bridges/otellogrus"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
@ -24,16 +23,13 @@ var (
//go:embed migrations/*.sql
embedMigrations embed.FS
client *gorm.DB
tracer trace.Tracer
tracer = otel.Tracer(tracingName)
logger = log.New()
)
// Connect to the Database
func Connect(ctx context.Context, config models.DatabaseConfig) error {
// Setup open telemetry
tracer = otel.Tracer(tracingName)
hook := otellogrus.NewHook(tracingName)
logger.AddHook(hook)