Skip to content

Commit 1ca6a8a

Browse files
committed
print dbos version during DBOSContext.Initialize
1 parent 952f702 commit 1ca6a8a

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

dbos/dbos.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"log/slog"
1212
"os"
1313
"path/filepath"
14+
"runtime/debug"
1415
"sync"
1516
"sync/atomic"
1617
"time"
@@ -307,7 +308,7 @@ func NewDBOSContext(ctx context.Context, inputConfig Config) (DBOSContext, error
307308

308309
// Set global logger
309310
initExecutor.logger = config.Logger
310-
initExecutor.logger.Info("Initializing DBOS context", "app_name", config.AppName)
311+
initExecutor.logger.Info("Initializing DBOS context", "app_name", config.AppName, "dbos_version", getDBOSVersion())
311312

312313
// Register types we serialize with gob
313314
var t time.Time
@@ -421,7 +422,7 @@ func (c *dbosContext) Launch() error {
421422
c.logger.Debug("No pending workflows to recover")
422423
}
423424

424-
c.logger.Info("DBOS initialized", "app_version", c.applicationVersion, "executor_id", c.executorID)
425+
c.logger.Info("DBOS launched", "app_version", c.applicationVersion, "executor_id", c.executorID)
425426
c.launched.Store(true)
426427
return nil
427428
}
@@ -556,3 +557,19 @@ func computeApplicationVersion() string {
556557
}
557558
return hash
558559
}
560+
561+
// getDBOSVersion returns the version of the DBOS module
562+
func getDBOSVersion() string {
563+
if info, ok := debug.ReadBuildInfo(); ok {
564+
for _, dep := range info.Deps {
565+
if dep.Path == "github.com/dbos-inc/dbos-transact-golang" {
566+
return dep.Version
567+
}
568+
}
569+
// If running as main module, return main module version
570+
if info.Main.Path == "github.com/dbos-inc/dbos-transact-golang" {
571+
return info.Main.Version
572+
}
573+
}
574+
return "unknown"
575+
}

0 commit comments

Comments
 (0)