Skip to content

Commit

Permalink
Add logs for test run when system state collection is skipped (#456)
Browse files Browse the repository at this point in the history
* Add logs for test run when system state collection is skipped

* Update log message

Co-authored-by: Maciek Sakrejda <[email protected]>

---------

Co-authored-by: Maciek Sakrejda <[email protected]>
  • Loading branch information
keiko713 and msakrejda authored Sep 21, 2023
1 parent 4e91a60 commit 681200c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion input/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func CollectFull(ctx context.Context, server *state.Server, connection *sql.DB,
}

if globalCollectionOpts.CollectSystemInformation {
ps.System = system.GetSystemState(server.Config, logger)
ps.System = system.GetSystemState(server.Config, logger, globalCollectionOpts)
}

server.SetLogTimezone(ts.Settings)
Expand Down
12 changes: 11 additions & 1 deletion input/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func DownloadLogFiles(ctx context.Context, server *state.Server, globalCollectio
}

// GetSystemState - Retrieves a system snapshot for this system and returns it
func GetSystemState(config config.ServerConfig, logger *util.Logger) (system state.SystemState) {
func GetSystemState(config config.ServerConfig, logger *util.Logger, globalCollectionOpts state.CollectionOpts) (system state.SystemState) {
dbHost := config.GetDbHost()
if config.SystemType == "amazon_rds" {
system = rds.GetSystemState(config, logger)
Expand All @@ -46,8 +46,18 @@ func GetSystemState(config config.ServerConfig, logger *util.Logger) (system sta
// runs on the database server itself and can gather local statistics
system = selfhosted.GetSystemState(config, logger)
system.Info.Type = state.CrunchyBridgeSystem
} else if config.SystemType == "aiven" {
system.Info.Type = state.AivenSystem
} else if dbHost == "" || dbHost == "localhost" || dbHost == "127.0.0.1" || config.AlwaysCollectSystemData {
system = selfhosted.GetSystemState(config, logger)
} else {
if globalCollectionOpts.TestRun {
// Detected as self hosted, but not collecting system state as we
// didn't detect the collector is running on the same instance as
// the database server.
// Leave logs for if this is a test run.
logger.PrintInfo("Skipping collection of system state: remote host (%s) was specified for the database address. Consider enabling always_collect_system_data if the database is running on the same system as the collector", dbHost)
}
}

system.Info.SystemID = config.SystemID
Expand Down

0 comments on commit 681200c

Please sign in to comment.