From 6fd9e75d47fbc2b78774e27922848f644cbe5bf7 Mon Sep 17 00:00:00 2001 From: Sorin Dumitru Date: Tue, 5 Nov 2024 23:04:23 +0000 Subject: [PATCH] spire-server/agent: log version at start up (#5637) Signed-off-by: Sorin Dumitru --- pkg/agent/agent.go | 6 +++++- pkg/server/server.go | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/agent/agent.go b/pkg/agent/agent.go index 6b3f2d62a7..e32a500707 100644 --- a/pkg/agent/agent.go +++ b/pkg/agent/agent.go @@ -32,6 +32,7 @@ import ( "github.com/spiffe/spire/pkg/common/telemetry" "github.com/spiffe/spire/pkg/common/uptime" "github.com/spiffe/spire/pkg/common/util" + "github.com/spiffe/spire/pkg/common/version" _ "golang.org/x/net/trace" // registers handlers on the DefaultServeMux "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -51,7 +52,10 @@ type Agent struct { // This method initializes the agent, including its plugins, // and then blocks on the main event loop. func (a *Agent) Run(ctx context.Context) error { - a.c.Log.Infof("Starting agent with data directory: %q", a.c.DataDir) + a.c.Log.WithFields(logrus.Fields{ + telemetry.DataDir: a.c.DataDir, + telemetry.Version: version.Version(), + }).Info("Starting agent") if err := diskutil.CreateDataDirectory(a.c.DataDir); err != nil { return err } diff --git a/pkg/server/server.go b/pkg/server/server.go index f0fcabfe17..27db8ca41b 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -21,6 +21,7 @@ import ( "github.com/spiffe/spire/pkg/common/telemetry" "github.com/spiffe/spire/pkg/common/uptime" "github.com/spiffe/spire/pkg/common/util" + "github.com/spiffe/spire/pkg/common/version" "github.com/spiffe/spire/pkg/server/authpolicy" bundle_client "github.com/spiffe/spire/pkg/server/bundle/client" ds_pubmanager "github.com/spiffe/spire/pkg/server/bundle/datastore" @@ -74,6 +75,7 @@ func (s *Server) run(ctx context.Context) (err error) { telemetry.AdminIDs: s.config.AdminIDs, telemetry.DataDir: s.config.DataDir, telemetry.LaunchLogLevel: s.config.Log.GetLevel(), + telemetry.Version: version.Version(), }).Info("Configured") // create the data directory if needed