diff --git a/tracer/tracer.go b/tracer/tracer.go index f25bec4c4..fc08f22a0 100644 --- a/tracer/tracer.go +++ b/tracer/tracer.go @@ -522,6 +522,34 @@ func rewriteMaps(coll *cebpf.CollectionSpec, maps map[string]*cebpf.Map) error { return nil } +// isTracerEnabled checks if an interpreter tracer for the given map is enabled. +func isTracerEnabled(mapName string, includeTracers types.IncludedTracers) bool { + switch mapName { + case "perl_procs": + return includeTracers.Has(types.PerlTracer) + case "php_procs": + return includeTracers.Has(types.PHPTracer) + case "py_procs": + return includeTracers.Has(types.PythonTracer) + case "hotspot_procs": + return includeTracers.Has(types.HotspotTracer) + case "ruby_procs": + return includeTracers.Has(types.RubyTracer) + case "v8_procs": + return includeTracers.Has(types.V8Tracer) + case "dotnet_procs": + return includeTracers.Has(types.DotnetTracer) + case "beam_procs": + return includeTracers.Has(types.BEAMTracer) + case "go_labels_procs", "apm_int_procs": + // go_labels_procs and apm_int_procs are called from + // unwind_stop and therefore need to be available all the time. + return true + default: + return true // Not an interpreter map, so it should be loaded + } +} + // loadAllMaps loads all eBPF maps that are used in our eBPF programs. func loadAllMaps(coll *cebpf.CollectionSpec, cfg *Config, ebpfMaps map[string]*cebpf.Map, @@ -559,6 +587,11 @@ func loadAllMaps(coll *cebpf.CollectionSpec, cfg *Config, // Off CPU Profiling is disabled. So do not load this map. continue } + + if !isTracerEnabled(mapName, cfg.IncludeTracers) { + log.Debugf("Skipping eBPF map %s: tracer not enabled", mapName) + continue + } if newSize, ok := adaption[mapName]; ok { log.Debugf("Size of eBPF map %s: %v", mapName, newSize) mapSpec.MaxEntries = newSize