Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/hostmetrics] Add cache_boot_time field to process scrapers #31998

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ type Config struct {
// MetricsBuilderConfig allows customizing scraped metrics/attributes representation.
metadata.MetricsBuilderConfig `mapstructure:",squash"`
internal.ScraperConfig

// CacheBootTime enables caching of the boot time of the system and each process. This means the
// boot times will never be updated as long as the collector is running.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the downsides of enabling it? Should we consider enabling it without a config option?

CacheBootTime bool `mapstructure:"cache_boot_time"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ type processesMetadata struct {

// newProcessesScraper creates a set of Processes related metrics
func newProcessesScraper(_ context.Context, settings receiver.CreateSettings, cfg *Config) *scraper {
if cfg.CacheBootTime {
host.EnableBootTimeCache(true)
process.EnableBootTimeCache(true)
}
return &scraper{
settings: settings,
config: cfg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ type Config struct {
// ScrapeProcessDelay is used to indicate the minimum amount of time a process must be running
// before metrics are scraped for it. The default value is 0 seconds (0s)
ScrapeProcessDelay time.Duration `mapstructure:"scrape_process_delay"`

// CacheBootTime is used to enable functionality to cache the system boot time at the start of
// the process. With this enabled, the boot time will never update as long as the collector process
// is running.
CacheBootTime bool `mapstructure:"cache_boot_time"`
}

type MatchConfig struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func newProcessScraper(settings receiver.CreateSettings, cfg *Config) (*scraper,

scraper.logicalCores = logicalCores

if cfg.CacheBootTime {
process.EnableBootTimeCache(true)
}

return scraper, nil
}

Expand Down
Loading