Skip to content

Commit 1dd69e3

Browse files
committed
fix(bootstrap): Don't compile rules if filament is supplied
Avoid compiling ruleset if the Fibratus is instructed to the run the filament.
1 parent bb3e60c commit 1dd69e3

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

internal/bootstrap/bootstrap.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func NewApp(cfg *config.Config, options ...Option) (*App, error) {
138138
var engine *rules.Engine
139139
var rs *config.RulesCompileResult
140140

141-
if cfg.Filters.Rules.Enabled && !cfg.ForwardMode && !cfg.IsCaptureSet() {
141+
if cfg.Filters.Rules.Enabled && !cfg.ForwardMode && !cfg.IsCaptureSet() && !cfg.IsFilamentSet() {
142142
engine = rules.NewEngine(psnap, cfg)
143143
var err error
144144
rs, err = engine.Compile()
@@ -203,9 +203,8 @@ func (f *App) Run(args []string) error {
203203
// In case of a regular run, we additionally set up the aggregator.
204204
// The aggregator will grab the events from the queue, assemble them
205205
// into batches and hand over to output sinks.
206-
filamentName := cfg.Filament.Name
207-
if filamentName != "" {
208-
f.filament, err = filament.New(filamentName, f.psnap, f.hsnap, cfg)
206+
if cfg.IsFilamentSet() {
207+
f.filament, err = filament.New(cfg.Filament.Name, f.psnap, f.hsnap, cfg)
209208
if err != nil {
210209
return err
211210
}
@@ -314,9 +313,9 @@ func (f *App) ReadCapture(ctx context.Context, args []string) error {
314313
if err != nil {
315314
return err
316315
}
317-
filamentName := f.config.Filament.Name
318-
if filamentName != "" {
319-
f.filament, err = filament.New(filamentName, f.psnap, f.hsnap, f.config)
316+
317+
if f.config.IsFilamentSet() {
318+
f.filament, err = filament.New(f.config.Filament.Name, f.psnap, f.hsnap, f.config)
320319
if err != nil {
321320
return err
322321
}
@@ -355,6 +354,7 @@ func (f *App) ReadCapture(ctx context.Context, args []string) error {
355354
return err
356355
}
357356
}
357+
358358
return api.StartServer(f.config)
359359
}
360360

pkg/config/config_windows.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ func (c *Config) Init() error {
310310
// in the capture file.
311311
func (c *Config) IsCaptureSet() bool { return c.CapFile != "" }
312312

313+
// IsFilamentSet indicates if the filament is supplied.
314+
func (c *Config) IsFilamentSet() bool { return c.Filament.Name != "" }
315+
313316
// TryLoadFile attempts to load the configuration file from specified path on the file system.
314317
func (c *Config) TryLoadFile(file string) error {
315318
c.viper.SetConfigFile(file)

0 commit comments

Comments
 (0)