@@ -26,9 +26,7 @@ import (
2626 "go.opentelemetry.io/ebpf-profiler/host"
2727 "go.opentelemetry.io/ebpf-profiler/libpf"
2828 "go.opentelemetry.io/ebpf-profiler/metrics"
29- otelreporter "go.opentelemetry.io/ebpf-profiler/reporter"
3029 "go.opentelemetry.io/ebpf-profiler/times"
31- "go.opentelemetry.io/ebpf-profiler/tracehandler"
3230 "go.opentelemetry.io/ebpf-profiler/tracer"
3331 tracertypes "go.opentelemetry.io/ebpf-profiler/tracer/types"
3432 "go.opentelemetry.io/otel/metric/noop"
@@ -58,19 +56,29 @@ const (
5856 defaultProcessesCacheSize = 16384
5957)
6058
61- func startTraceHandling (ctx context.Context , rep otelreporter.TraceReporter ,
62- intervals * times.Times , trc * tracer.Tracer , cacheSize uint32 ) error {
59+ func startTraceHandling (ctx context.Context , trc * tracer.Tracer ) error {
6360 // Spawn monitors for the various result maps
6461 traceCh := make (chan * host.Trace )
6562
6663 if err := trc .StartMapMonitors (ctx , traceCh ); err != nil {
6764 return fmt .Errorf ("failed to start map monitors: %w" , err )
6865 }
6966
70- _ , err := tracehandler .Start (ctx , rep , trc .TraceProcessor (),
71- traceCh , intervals , cacheSize )
67+ go func () {
68+ // Poll the output channels
69+ for {
70+ select {
71+ case trace := <- traceCh :
72+ if trace != nil {
73+ trc .HandleTrace (trace )
74+ }
75+ case <- ctx .Done ():
76+ return
77+ }
78+ }
79+ }()
7280
73- return err
81+ return nil
7482}
7583
7684func appendEndpoint (symbolEndpoints []reporter.SymbolEndpoint , site , apiKey , appKey string ) []reporter.SymbolEndpoint {
@@ -155,9 +163,6 @@ func Run(mainCtx context.Context, c *config.Config) ExitCode {
155163 return failure ("Failed to probe eBPF syscall: %v" , err )
156164 }
157165
158- // disable trace handler cache because it consumes too much memory for almost no CPU benefit
159- traceHandlerCacheSize := uint32 (0 )
160-
161166 intervals := times .New (c .ReporterInterval , c .MonitorInterval ,
162167 c .ProbabilisticInterval )
163168
@@ -293,6 +298,7 @@ func Run(mainCtx context.Context, c *config.Config) ExitCode {
293298
294299 // Load the eBPF code and map definitions
295300 trc , err := tracer .NewTracer (mainCtx , & tracer.Config {
301+ TraceReporter : rep ,
296302 ExecutableReporter : rep ,
297303 Intervals : intervals ,
298304 IncludeTracers : includeTracers ,
@@ -305,6 +311,7 @@ func Run(mainCtx context.Context, c *config.Config) ExitCode {
305311 ProbabilisticInterval : c .ProbabilisticInterval ,
306312 ProbabilisticThreshold : uint (c .ProbabilisticThreshold ),
307313 IncludeEnvVars : includeEnvVars ,
314+ FrameCacheSize : int (c .FrameCacheSize ),
308315 })
309316 if err != nil {
310317 return failure ("Failed to load eBPF tracer: %v" , err )
@@ -340,7 +347,7 @@ func Run(mainCtx context.Context, c *config.Config) ExitCode {
340347 // change this log line update also the system test.
341348 log .Printf ("Attached sched monitor" )
342349
343- if err := startTraceHandling (mainCtx , rep , intervals , trc , traceHandlerCacheSize ); err != nil {
350+ if err := startTraceHandling (mainCtx , trc ); err != nil {
344351 return failure ("Failed to start trace handling: %v" , err )
345352 }
346353
0 commit comments