From 9302cf1af0b619aa9d22a5b0e0b296c339dd7130 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Mon, 6 Jan 2025 18:23:48 -0600 Subject: [PATCH] Fix typo in EBPFTracer (#1494) --- pkg/beyla/config.go | 4 ++-- pkg/beyla/config_test.go | 6 +++--- pkg/config/ebpf_tracer.go | 4 ++-- pkg/internal/ebpf/common/common.go | 2 +- pkg/internal/ebpf/common/ringbuf.go | 10 +++++----- pkg/internal/ebpf/common/ringbuf_test.go | 6 +++--- pkg/internal/ebpf/common/tcp_detect_transform.go | 2 +- pkg/internal/ebpf/common/tcp_detect_transform_test.go | 2 +- pkg/internal/ebpf/gotracer/gotracer.go | 2 +- pkg/internal/ebpf/logger/logger.go | 2 +- pkg/internal/ebpf/watcher/watcher.go | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pkg/beyla/config.go b/pkg/beyla/config.go index 5ec03b914..c5b285a26 100644 --- a/pkg/beyla/config.go +++ b/pkg/beyla/config.go @@ -44,7 +44,7 @@ var DefaultConfig = Config{ ChannelBufferLen: 10, LogLevel: "INFO", EnforceSysCaps: false, - EBPF: config.EPPFTracer{ + EBPF: config.EBPFTracer{ BatchLength: 100, BatchTimeout: time.Second, HTTPRequestTimeout: 30 * time.Second, @@ -132,7 +132,7 @@ var DefaultConfig = Config{ } type Config struct { - EBPF config.EPPFTracer `yaml:"ebpf"` + EBPF config.EBPFTracer `yaml:"ebpf"` // NetworkFlows configuration for Network Observability feature NetworkFlows NetworkConfig `yaml:"network"` diff --git a/pkg/beyla/config_test.go b/pkg/beyla/config_test.go index 75c864e65..6f4e17135 100644 --- a/pkg/beyla/config_test.go +++ b/pkg/beyla/config_test.go @@ -120,7 +120,7 @@ network: EnforceSysCaps: false, Printer: false, TracePrinter: "json", - EBPF: config.EPPFTracer{ + EBPF: config.EBPFTracer{ BatchLength: 100, BatchTimeout: time.Second, HTTPRequestTimeout: 30 * time.Second, @@ -458,7 +458,7 @@ time=\S+ level=DEBUG msg=debug arg=debug$`), tracing: true, expectedCfg: Config{ TracePrinter: debug.TracePrinterText, - EBPF: config.EPPFTracer{BpfDebug: true}, + EBPF: config.EBPFTracer{BpfDebug: true}, }, }, { name: "debug log with network flows", @@ -472,7 +472,7 @@ time=\S+ level=DEBUG msg=debug arg=debug$`), tracing: true, expectedCfg: Config{ TracePrinter: debug.TracePrinterText, - EBPF: config.EPPFTracer{BpfDebug: true}, + EBPF: config.EBPFTracer{BpfDebug: true}, NetworkFlows: NetworkConfig{Enable: true, Print: true}, }, }} { diff --git a/pkg/config/ebpf_tracer.go b/pkg/config/ebpf_tracer.go index cc2b4217f..f81ef2e0e 100644 --- a/pkg/config/ebpf_tracer.go +++ b/pkg/config/ebpf_tracer.go @@ -2,8 +2,8 @@ package config import "time" -// EPPFTracer configuration for eBPF programs -type EPPFTracer struct { +// EBPFTracer configuration for eBPF programs +type EBPFTracer struct { BpfDebug bool `yaml:"bpf_debug" env:"BEYLA_BPF_DEBUG"` // WakeupLen specifies how many messages need to be accumulated in the eBPF ringbuffer diff --git a/pkg/internal/ebpf/common/common.go b/pkg/internal/ebpf/common/common.go index c8d22d987..0f8a75ce2 100644 --- a/pkg/internal/ebpf/common/common.go +++ b/pkg/internal/ebpf/common/common.go @@ -103,7 +103,7 @@ var MisclassifiedEvents = make(chan MisclassifiedEvent) func ptlog() *slog.Logger { return slog.With("component", "ebpf.ProcessTracer") } -func ReadBPFTraceAsSpan(cfg *config.EPPFTracer, record *ringbuf.Record, filter ServiceFilter) (request.Span, bool, error) { +func ReadBPFTraceAsSpan(cfg *config.EBPFTracer, record *ringbuf.Record, filter ServiceFilter) (request.Span, bool, error) { var eventType uint8 // we read the type first, depending on the type we decide what kind of record we have diff --git a/pkg/internal/ebpf/common/ringbuf.go b/pkg/internal/ebpf/common/ringbuf.go index 3a33e4c5e..bcbf031fe 100644 --- a/pkg/internal/ebpf/common/ringbuf.go +++ b/pkg/internal/ebpf/common/ringbuf.go @@ -30,7 +30,7 @@ var readerFactory = func(rb *ebpf.Map) (ringBufReader, error) { } type ringBufForwarder struct { - cfg *config.EPPFTracer + cfg *config.EBPFTracer logger *slog.Logger ringbuffer *ebpf.Map closers []io.Closer @@ -38,7 +38,7 @@ type ringBufForwarder struct { spansLen int access sync.Mutex ticker *time.Ticker - reader func(*config.EPPFTracer, *ringbuf.Record, ServiceFilter) (request.Span, bool, error) + reader func(*config.EBPFTracer, *ringbuf.Record, ServiceFilter) (request.Span, bool, error) // filter the input spans, eliminating these from processes whose PID // belong to a process that does not match the discovery policies filter ServiceFilter @@ -52,7 +52,7 @@ var singleRbfLock sync.Mutex // internal buffer, and forwards them to an output events channel, previously converted to request.Span // instances. func SharedRingbuf( - cfg *config.EPPFTracer, + cfg *config.EBPFTracer, filter ServiceFilter, ringbuffer *ebpf.Map, metrics imetrics.Reporter, @@ -75,10 +75,10 @@ func SharedRingbuf( } func ForwardRingbuf( - cfg *config.EPPFTracer, + cfg *config.EBPFTracer, ringbuffer *ebpf.Map, filter ServiceFilter, - reader func(*config.EPPFTracer, *ringbuf.Record, ServiceFilter) (request.Span, bool, error), + reader func(*config.EBPFTracer, *ringbuf.Record, ServiceFilter) (request.Span, bool, error), logger *slog.Logger, metrics imetrics.Reporter, closers ...io.Closer, diff --git a/pkg/internal/ebpf/common/ringbuf_test.go b/pkg/internal/ebpf/common/ringbuf_test.go index 31b193466..1dc980260 100644 --- a/pkg/internal/ebpf/common/ringbuf_test.go +++ b/pkg/internal/ebpf/common/ringbuf_test.go @@ -34,7 +34,7 @@ func TestForwardRingbuf_CapacityFull(t *testing.T) { fltr := TestPidsFilter{services: map[uint32]svc.Attrs{}} fltr.AllowPID(1, 1, &svc.Attrs{UID: svc.UID{Name: "myService"}}, PIDTypeGo) go ForwardRingbuf( - &config.EPPFTracer{BatchLength: 10}, + &config.EBPFTracer{BatchLength: 10}, nil, // the source ring buffer can be null &fltr, ReadBPFTraceAsSpan, @@ -86,7 +86,7 @@ func TestForwardRingbuf_Deadline(t *testing.T) { fltr := TestPidsFilter{services: map[uint32]svc.Attrs{}} fltr.AllowPID(1, 1, &svc.Attrs{UID: svc.UID{Name: "myService"}}, PIDTypeGo) go ForwardRingbuf( - &config.EPPFTracer{BatchLength: 10, BatchTimeout: 20 * time.Millisecond}, + &config.EBPFTracer{BatchLength: 10, BatchTimeout: 20 * time.Millisecond}, nil, // the source ring buffer can be null &fltr, // change fltr to a pointer ReadBPFTraceAsSpan, @@ -126,7 +126,7 @@ func TestForwardRingbuf_Close(t *testing.T) { metrics := &metricsReporter{} closable := closableObject{} go ForwardRingbuf( - &config.EPPFTracer{BatchLength: 10}, + &config.EBPFTracer{BatchLength: 10}, nil, // the source ring buffer can be null (&IdentityPidsFilter{}), ReadBPFTraceAsSpan, diff --git a/pkg/internal/ebpf/common/tcp_detect_transform.go b/pkg/internal/ebpf/common/tcp_detect_transform.go index 706c3e553..0a56d5de0 100644 --- a/pkg/internal/ebpf/common/tcp_detect_transform.go +++ b/pkg/internal/ebpf/common/tcp_detect_transform.go @@ -11,7 +11,7 @@ import ( ) // nolint:cyclop -func ReadTCPRequestIntoSpan(cfg *config.EPPFTracer, record *ringbuf.Record, filter ServiceFilter) (request.Span, bool, error) { +func ReadTCPRequestIntoSpan(cfg *config.EBPFTracer, record *ringbuf.Record, filter ServiceFilter) (request.Span, bool, error) { var event TCPRequestInfo err := binary.Read(bytes.NewBuffer(record.RawSample), binary.LittleEndian, &event) diff --git a/pkg/internal/ebpf/common/tcp_detect_transform_test.go b/pkg/internal/ebpf/common/tcp_detect_transform_test.go index 1ac49e010..99f06761e 100644 --- a/pkg/internal/ebpf/common/tcp_detect_transform_test.go +++ b/pkg/internal/ebpf/common/tcp_detect_transform_test.go @@ -99,7 +99,7 @@ func TestReadTCPRequestIntoSpan_Overflow(t *testing.T) { }, } - cfg := config.EPPFTracer{HeuristicSQLDetect: true} + cfg := config.EBPFTracer{HeuristicSQLDetect: true} binaryRecord := bytes.Buffer{} require.NoError(t, binary.Write(&binaryRecord, binary.LittleEndian, tri)) diff --git a/pkg/internal/ebpf/gotracer/gotracer.go b/pkg/internal/ebpf/gotracer/gotracer.go index 6ba102c5c..d37b7edd5 100644 --- a/pkg/internal/ebpf/gotracer/gotracer.go +++ b/pkg/internal/ebpf/gotracer/gotracer.go @@ -40,7 +40,7 @@ import ( type Tracer struct { log *slog.Logger pidsFilter ebpfcommon.ServiceFilter - cfg *config.EPPFTracer + cfg *config.EBPFTracer metrics imetrics.Reporter bpfObjects bpfObjects closers []io.Closer diff --git a/pkg/internal/ebpf/logger/logger.go b/pkg/internal/ebpf/logger/logger.go index c280d96f9..579abb8f6 100644 --- a/pkg/internal/ebpf/logger/logger.go +++ b/pkg/internal/ebpf/logger/logger.go @@ -77,7 +77,7 @@ func (p *BPFLogger) Run(ctx context.Context) { )(ctx, nil) } -func (p *BPFLogger) processLogEvent(_ *config.EPPFTracer, record *ringbuf.Record, _ ebpfcommon.ServiceFilter) (request.Span, bool, error) { +func (p *BPFLogger) processLogEvent(_ *config.EBPFTracer, record *ringbuf.Record, _ ebpfcommon.ServiceFilter) (request.Span, bool, error) { var event BPFLogInfo err := binary.Read(bytes.NewBuffer(record.RawSample), binary.LittleEndian, &event) diff --git a/pkg/internal/ebpf/watcher/watcher.go b/pkg/internal/ebpf/watcher/watcher.go index c7e01e0af..1519cbe3c 100644 --- a/pkg/internal/ebpf/watcher/watcher.go +++ b/pkg/internal/ebpf/watcher/watcher.go @@ -97,7 +97,7 @@ func (p *Watcher) Run(ctx context.Context) { )(ctx, nil) } -func (p *Watcher) processWatchEvent(_ *config.EPPFTracer, record *ringbuf.Record, _ ebpfcommon.ServiceFilter) (request.Span, bool, error) { +func (p *Watcher) processWatchEvent(_ *config.EBPFTracer, record *ringbuf.Record, _ ebpfcommon.ServiceFilter) (request.Span, bool, error) { var flags uint64 var event BPFWatchInfo