Skip to content

Commit

Permalink
tetragon: Move base sensor initialization to GetInitialSensor
Browse files Browse the repository at this point in the history
Currently we initialize the base sensor when the sensor when
the application is started even for command like --help which
does not really needs it.

Moving the progs/maps sensor init to GetInitialSensor so it's
initialized when the sensor is actually needed.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Dec 20, 2023
1 parent 3267a03 commit d5ca9c8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/sensors/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ var (
StatsMap = program.MapBuilder("tg_stats_map", Execve)

sensor = sensors.Sensor{
Name: "__base__",
Progs: GetDefaultPrograms(),
Maps: GetDefaultMaps(),
Name: "__base__",
}
sensorInit sync.Once
)

func GetExecveMap() *program.Map {
Expand Down Expand Up @@ -104,6 +103,10 @@ func GetDefaultMaps() []*program.Map {

// GetInitialSensor returns the base sensor
func GetInitialSensor() *sensors.Sensor {
sensorInit.Do(func() {
sensor.Progs = GetDefaultPrograms()
sensor.Maps = GetDefaultMaps()
})
return &sensor
}

Expand Down

0 comments on commit d5ca9c8

Please sign in to comment.