From e6c0b2f765a7c964af1decbf5c72cb9c92d764d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20M=C3=A4kinen?= Date: Thu, 31 Oct 2024 11:09:44 +1100 Subject: [PATCH] fix: log database connections from go runtime (#3253) --- go-runtime/ftl/database.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/go-runtime/ftl/database.go b/go-runtime/ftl/database.go index c0c6717654..e434e3f94a 100644 --- a/go-runtime/ftl/database.go +++ b/go-runtime/ftl/database.go @@ -12,6 +12,7 @@ import ( "go.opentelemetry.io/otel/attribute" semconv "go.opentelemetry.io/otel/semconv/v1.4.0" + "github.com/TBD54566975/ftl/internal/log" "github.com/TBD54566975/ftl/internal/modulecontext" ) @@ -28,11 +29,15 @@ func PostgresDatabase(name string) Database { Name: name, DBType: modulecontext.DBTypePostgres, db: once.Once(func(ctx context.Context) (*sql.DB, error) { + logger := log.FromContext(ctx) + provider := modulecontext.FromContext(ctx).CurrentContext() dsn, err := provider.GetDatabase(name, modulecontext.DBTypePostgres) if err != nil { return nil, fmt.Errorf("failed to get database %q: %w", name, err) } + + logger.Debugf("Opening database: %s", name) db, err := otelsql.Open("pgx", dsn) if err != nil { return nil, fmt.Errorf("failed to open database %q: %w", name, err)