Skip to content

Commit

Permalink
[receiver/purefa] Adds a new scrapper type directories (open-telemetr…
Browse files Browse the repository at this point in the history
  • Loading branch information
dgoscn authored Dec 5, 2022
1 parent 761def3 commit b0de453
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions receiver/purefareceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ type Config struct {

// Hosts represents the list of hosts to query
Hosts []internal.ScraperConfig `mapstructure:"hosts"`

// Directories represents the list of directories to query
Directories []internal.ScraperConfig `mapstructure:"directories"`
}

type Settings struct {
ReloadIntervals *ReloadIntervals `mapstructure:"reload_intervals"`
}

type ReloadIntervals struct {
Array time.Duration `mapstructure:"array"`
Host time.Duration `mapstructure:"host"`
Array time.Duration `mapstructure:"array"`
Host time.Duration `mapstructure:"host"`
Directories time.Duration `mapstructure:"directories"`
}

func (c *Config) Validate() error {
Expand Down
5 changes: 3 additions & 2 deletions receiver/purefareceiver/internal/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ type Scraper interface {
type ScraperType string

const (
ScraperTypeArray ScraperType = "array"
ScraperTypeHost ScraperType = "host"
ScraperTypeArray ScraperType = "array"
ScraperTypeHost ScraperType = "host"
ScraperTypeDirectories ScraperType = "directories"
)

type scraper struct {
Expand Down
7 changes: 7 additions & 0 deletions receiver/purefareceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ func (r *purefaReceiver) Start(ctx context.Context, compHost component.Host) err
return err
}

directoriesScraper := internal.NewScraper(ctx, internal.ScraperTypeDirectories, r.cfg.Endpoint, r.cfg.Hosts, r.cfg.Settings.ReloadIntervals.Host)
if scCfgs, err := directoriesScraper.ToPrometheusReceiverConfig(compHost, fact); err == nil {
scrapeCfgs = append(scrapeCfgs, scCfgs...)
} else {
return err
}

promRecvCfg := fact.CreateDefaultConfig().(*prometheusreceiver.Config)
promRecvCfg.PrometheusConfig = &config.Config{ScrapeConfigs: scrapeCfgs}

Expand Down

0 comments on commit b0de453

Please sign in to comment.