in internal/flavors/posture.go [49:93]
func newPostureFromCfg(b *beat.Beat, cfg *config.Config) (*posture, error) {
log := clog.NewLogger("posture")
log.Info("Config initiated with cycle period of ", cfg.Period)
ctx, cancel := context.WithCancel(context.Background())
strategy, err := benchmark.GetStrategy(cfg, log)
if err != nil {
cancel()
return nil, err
}
log.Infof("Creating benchmark %T", strategy)
bench, err := strategy.NewBenchmark(ctx, log, cfg)
if err != nil {
cancel()
return nil, err
}
err = ensureHostProcessor(log, cfg)
if err != nil {
cancel()
return nil, err
}
client, err := NewClient(b.Publisher, cfg.Processors)
if err != nil {
cancel()
return nil, fmt.Errorf("failed to init client: %w", err)
}
log.Infof("posture configured %d processors", len(cfg.Processors))
publisher := NewPublisher(log, flushInterval, eventsThreshold, client)
return &posture{
flavorBase: flavorBase{
ctx: ctx,
cancel: cancel,
publisher: publisher,
config: cfg,
log: log,
client: client,
},
benchmark: bench,
}, nil
}