Skip to content

Commit

Permalink
Merge pull request #6 from kubescape/feature/integ
Browse files Browse the repository at this point in the history
Removing external managed code support
  • Loading branch information
amitschendel authored Oct 20, 2024
2 parents 20d4985 + 481403f commit 01bcfe8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
3 changes: 0 additions & 3 deletions cli_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ type arguments struct {
samplesPerSecond int
sendErrorFrames bool
tracers string
externallyManaged bool
verboseMode bool
version bool

Expand Down Expand Up @@ -136,8 +135,6 @@ func parseArgs() (*arguments, error) {
fs.StringVar(&args.tracers, "t", "all", "Shorthand for -tracers.")
fs.StringVar(&args.tracers, "tracers", "all", tracersHelp)

fs.BoolVar(&args.externallyManaged, "externally-managed", false, externallyManagedHelp)

fs.BoolVar(&args.verboseMode, "v", false, "Shorthand for -verbose.")
fs.BoolVar(&args.verboseMode, "verbose", false, verboseModeHelp)
fs.BoolVar(&args.version, "version", false, versionHelp)
Expand Down
29 changes: 11 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,25 +227,18 @@ func mainWithExitCode() exitCode {
metrics.Add(metrics.IDProcPIDStartupMs, metrics.MetricValue(time.Since(now).Milliseconds()))
log.Debug("Completed initial PID listing")

if args.externallyManaged {
_, err := trc.GetNativeTracerEntry()
if err != nil {
return failure("Failed to get native tracer entry: %v", err)
}
// Attach our tracer to the perf event
if err := trc.AttachTracer(); err != nil {
return failure("Failed to attach to perf event: %v", err)
}
log.Info("Attached tracer program")

if args.probabilisticThreshold < tracer.ProbabilisticThresholdMax {
trc.StartProbabilisticProfiling(mainCtx)
log.Printf("Enabled probabilistic profiling")
} else {
// Attach our tracer to the perf event
if err := trc.AttachTracer(); err != nil {
return failure("Failed to attach to perf event: %v", err)
}
log.Info("Attached tracer program")

if args.probabilisticThreshold < tracer.ProbabilisticThresholdMax {
trc.StartProbabilisticProfiling(mainCtx)
log.Printf("Enabled probabilistic profiling")
} else {
if err := trc.EnableProfiling(); err != nil {
return failure("Failed to enable perf events: %v", err)
}
if err := trc.EnableProfiling(); err != nil {
return failure("Failed to enable perf events: %v", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ func (t *Tracer) TraceProcessor() tracehandler.TraceProcessor {
// GetNativeTracerEntry returns the file descriptor of the native tracer entry program.
// This allows the client to use the fd to trigger the eBPF program using tail calls.
func (t *Tracer) GetNativeTracerEntry() (int, error) {
tracerProg, ok := t.ebpfProgs["native_tracer_entry"]
tracerProg, ok := t.ebpfProgs["native_tracer_entry_kprobe"]
if !ok {
return 0, fmt.Errorf("entry program is not available")
}
Expand Down

0 comments on commit 01bcfe8

Please sign in to comment.