fix(observabillity): propagate ctx to every log call and add resource to logging
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 5m5s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 5m36s

This commit was merged in pull request #187.
This commit is contained in:
2025-06-17 09:42:19 +02:00
parent ff3c7bdf52
commit 6c92206b3c
27 changed files with 288 additions and 266 deletions

10
main.go
View File

@@ -14,26 +14,28 @@ import (
)
func main() {
ctx := context.Background()
err := godotenv.Load()
if err != nil {
slog.Error("Error loading .env file")
slog.ErrorContext(ctx, "Error loading .env file")
return
}
db, err := otelsqlx.Open("sqlite3", "./data/spend-sparrow.db",
otelsql.WithAttributes(semconv.DBSystemSqlite))
if err != nil {
slog.Error("Could not open Database data.db", "err", err)
slog.ErrorContext(ctx, "Could not open Database data.db", "err", err)
return
}
defer func() {
if err = db.Close(); err != nil {
slog.Error("Database close failed", "err", err)
slog.ErrorContext(ctx, "Database close failed", "err", err)
}
}()
if err = internal.Run(context.Background(), db, "", os.Getenv); err != nil {
slog.Error("Error running server", "err", err)
slog.ErrorContext(ctx, "Error running server", "err", err)
return
}
}