Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bpf2go:
prereqs: install-hooks bpf2go
@echo "### Check if prerequisites are met, and installing missing dependencies"
mkdir -p $(TEST_OUTPUT)/run
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,v1.61.0)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,v1.64.7)
$(call go-install-tool,$(GO_OFFSETS_TRACKER),github.com/grafana/go-offsets-tracker/cmd/go-offsets-tracker,$(call gomod-version,grafana/go-offsets-tracker))
$(call go-install-tool,$(GOIMPORTS_REVISER),github.com/incu6us/goimports-reviser/v3,v3.6.4)
$(call go-install-tool,$(GO_LICENSES),github.com/google/go-licenses,v1.6.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type expoHistogramDataPoint[N int64 | float64] struct {
zeroCount uint64
}

// nolint:revive
// lint disabled as this is an inherited code
func newExpoHistogramDataPoint[N int64 | float64](attrs attribute.Set, maxSize, maxScale int, noMinMax, noSum bool) *expoHistogramDataPoint[N] {
f := math.MaxFloat64
max := N(f) // if N is int64, max will overflow to -9223372036854775808
Expand Down
12 changes: 6 additions & 6 deletions pkg/export/otel/metrics_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,20 @@ func (p *InternalMetricsReporter) Start(ctx context.Context) {
p.beylaInfo.Record(ctx, 1, instrument.WithAttributes(attribute.String("goarch", runtime.GOARCH), attribute.String("goos", runtime.GOOS), attribute.String("goversion", runtime.Version()), attribute.String("version", buildinfo.Version), attribute.String("revision", buildinfo.Revision)))
}

func (p *InternalMetricsReporter) TracerFlush(len int) {
p.tracerFlushes.Record(p.ctx, float64(len))
func (p *InternalMetricsReporter) TracerFlush(length int) {
p.tracerFlushes.Record(p.ctx, float64(length))
}

func (p *InternalMetricsReporter) OTELMetricExport(len int) {
p.otelMetricExports.Add(p.ctx, float64(len))
func (p *InternalMetricsReporter) OTELMetricExport(length int) {
p.otelMetricExports.Add(p.ctx, float64(length))
}

func (p *InternalMetricsReporter) OTELMetricExportError(err error) {
p.otelMetricExportErrs.Add(p.ctx, 1, instrument.WithAttributes(attribute.String("error", err.Error())))
}

func (p *InternalMetricsReporter) OTELTraceExport(len int) {
p.otelTraceExports.Add(p.ctx, float64(len))
func (p *InternalMetricsReporter) OTELTraceExport(length int) {
p.otelTraceExports.Add(p.ctx, float64(length))
}

func (p *InternalMetricsReporter) OTELTraceExportError(err error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/export/otel/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,11 @@ func TestMetricsInterval(t *testing.T) {
})
}

func (f *fakeInternalMetrics) OTELMetricExport(len int) {
func (f *fakeInternalMetrics) OTELMetricExport(length int) {
fakeMux.Lock()
defer fakeMux.Unlock()
f.cnt.Add(1)
f.sum.Add(int32(len))
f.sum.Add(int32(length))
}

func (f *fakeInternalMetrics) OTELMetricExportError(_ error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/export/otel/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1188,9 +1188,9 @@ type fakeInternalTraces struct {
errs atomic.Int32
}

func (f *fakeInternalTraces) OTELTraceExport(len int) {
func (f *fakeInternalTraces) OTELTraceExport(length int) {
f.cnt.Add(1)
f.sum.Add(int32(len))
f.sum.Add(int32(length))
}

func (f *fakeInternalTraces) OTELTraceExportError(_ error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/ebpf/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/link"
"github.com/cilium/ebpf/ringbuf"

"github.com/grafana/beyla/v2/pkg/config"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/request"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/internal/ebpf/common/common_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ func HasHostNetworkAccess() (bool, error) {
return false, nil
}

func FindNetworkNamespace(pid int32) (string, error) {
func FindNetworkNamespace(_ int32) (string, error) {
return "", nil
}

func RootDirectoryForPID(pid int32) string {
func RootDirectoryForPID(_ int32) string {
return ""
}
2 changes: 1 addition & 1 deletion pkg/internal/ebpf/common/go_kafka_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"encoding/binary"
"unsafe"

"github.com/cilium/ebpf/ringbuf"
"go.opentelemetry.io/otel/trace"

"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/request"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/internal/ebpf/common/http2grpc_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"strings"
"unsafe"

"github.com/cilium/ebpf/ringbuf"
lru "github.com/hashicorp/golang-lru/v2"
"go.opentelemetry.io/otel/trace"
"golang.org/x/net/http2"

"github.com/grafana/beyla/v2/pkg/internal/ebpf/bhpack"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/request"
)

Expand Down Expand Up @@ -423,8 +423,8 @@ const (

const frameHeaderLen = 9

func readHTTP2Frame(buf []uint8, len int) (*frameHeader, bool) {
if len < frameHeaderLen {
func readHTTP2Frame(buf []uint8, length int) (*frameHeader, bool) {
if length < frameHeaderLen {
return nil, false
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/internal/ebpf/common/http2grpc_transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,17 @@ func TestDynamicTableUpdates(t *testing.T) {
assert.Equal(t, "*", s.Path) // this value is the same I just changed the first character from r to p
}

func makeBPFHTTP2Info(buf, rbuf []byte, len int) BPFHTTP2Info {
func makeBPFHTTP2Info(buf, rbuf []byte, length int) BPFHTTP2Info {
var info BPFHTTP2Info
copy(info.Data[:], buf)
copy(info.RetData[:], rbuf)
info.Len = int32(len)
info.Len = int32(length)

return info
}

func makeBPFHTTP2InfoNewRequest(buf, rbuf []byte, len int) BPFHTTP2Info {
info := makeBPFHTTP2Info(buf, rbuf, len)
func makeBPFHTTP2InfoNewRequest(buf, rbuf []byte, length int) BPFHTTP2Info {
info := makeBPFHTTP2Info(buf, rbuf, length)
info.ConnInfo.D_port = 1
info.ConnInfo.S_port = 1
info.NewConnId = 1
Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/ebpf/common/httpfltr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"testing"
"unsafe"

"github.com/cilium/ebpf/ringbuf"
"github.com/stretchr/testify/assert"

"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/request"
"github.com/grafana/beyla/v2/pkg/internal/svc"
)
Expand Down
3 changes: 1 addition & 2 deletions pkg/internal/ebpf/common/httpfltr_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
"strconv"
"strings"

"github.com/cilium/ebpf/ringbuf"

"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/request"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/ebpf/common/redis_detect_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"strings"
"unsafe"

"github.com/cilium/ebpf/ringbuf"
trace2 "go.opentelemetry.io/otel/trace"

"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/request"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/ebpf/common/ringbuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"time"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/ringbuf"

"github.com/grafana/beyla/v2/pkg/config"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/imetrics"
"github.com/grafana/beyla/v2/pkg/internal/request"
)
Expand Down
6 changes: 3 additions & 3 deletions pkg/internal/ebpf/common/ringbuf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"time"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/ringbuf"
"github.com/mariomac/guara/pkg/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/grafana/beyla/v2/pkg/config"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/imetrics"
"github.com/grafana/beyla/v2/pkg/internal/request"
"github.com/grafana/beyla/v2/pkg/internal/svc"
Expand Down Expand Up @@ -211,9 +211,9 @@ type metricsReporter struct {
flushedLen int
}

func (m *metricsReporter) TracerFlush(len int) {
func (m *metricsReporter) TracerFlush(length int) {
m.flushes++
m.flushedLen += len
m.flushedLen += length
}

type TestPidsFilter struct {
Expand Down
3 changes: 1 addition & 2 deletions pkg/internal/ebpf/common/tcp_detect_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"encoding/binary"
"fmt"

"github.com/cilium/ebpf/ringbuf"

"github.com/grafana/beyla/v2/pkg/config"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/request"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/ebpf/common/tcp_detect_transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"strings"
"testing"

"github.com/cilium/ebpf/ringbuf"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/grafana/beyla/v2/pkg/config"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/request"
"github.com/grafana/beyla/v2/pkg/internal/svc"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/ebpf/gpuevent/gpuevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
"sync"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/ringbuf"
"github.com/ianlancetaylor/demangle"
"github.com/prometheus/procfs"

"github.com/grafana/beyla/v2/pkg/beyla"
"github.com/grafana/beyla/v2/pkg/config"
ebpfcommon "github.com/grafana/beyla/v2/pkg/internal/ebpf/common"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/exec"
"github.com/grafana/beyla/v2/pkg/internal/goexec"
"github.com/grafana/beyla/v2/pkg/internal/imetrics"
Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/ebpf/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"log/slog"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/ringbuf"

"github.com/grafana/beyla/v2/pkg/beyla"
"github.com/grafana/beyla/v2/pkg/config"
ebpfcommon "github.com/grafana/beyla/v2/pkg/internal/ebpf/common"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/request"
)

Expand Down
14 changes: 14 additions & 0 deletions pkg/internal/ebpf/ringbuf/ringbuf_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Package ringbuf provides some type aliases to prevent testing/compilation
// errors in non-linux environments due to the use of Cilium's ringbuf package,
// which is only available on Linux.
package ringbuf

import (
"github.com/cilium/ebpf/ringbuf"
)

type Record = ringbuf.Record
type Reader = ringbuf.Reader

var ErrClosed = ringbuf.ErrClosed
var NewReader = ringbuf.NewReader
21 changes: 21 additions & 0 deletions pkg/internal/ebpf/ringbuf/ringbuf_notlinux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//go:build !linux

package ringbuf

import (
"io"
"os"
)

type Record struct {
RawSample []byte
}

var ErrClosed = os.ErrClosed

func NewReader(_ any) (interface {
io.Closer
Read() (Record, error)
}, error) {
return nil, nil
}
2 changes: 1 addition & 1 deletion pkg/internal/ebpf/tcmanager/dummymanager_notlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ func (d *dummyManager) AddProgram(_ string, _ *ebpf.Program, _ AttachmentType) {
func (d *dummyManager) RemoveProgram(_ string) {}
func (d *dummyManager) InterfaceName(_ int) (string, bool) { return "", false }
func (d *dummyManager) SetInterfaceManager(_ *InterfaceManager) {}
func (d *dummyManager) Errors() chan error {}
func (d *dummyManager) Errors() chan error { return nil }

func EnsureCiliumCompatibility(_ TCBackend) error { return nil }
2 changes: 1 addition & 1 deletion pkg/internal/ebpf/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"log/slog"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/ringbuf"

"github.com/grafana/beyla/v2/pkg/beyla"
"github.com/grafana/beyla/v2/pkg/config"
ebpfcommon "github.com/grafana/beyla/v2/pkg/internal/ebpf/common"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/request"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/internal/imetrics/imetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ type Reporter interface {
// Start the reporter
Start(ctx context.Context)
// TracerFlush is invoked every time the eBPF tracer flushes a group of len traces.
TracerFlush(len int)
TracerFlush(length int)
// OTELMetricExport is invoked every time the OpenTelemetry Metrics exporter successfully exports metrics to
// a remote collector. It accounts the length, in metrics, for each invocation.
OTELMetricExport(len int)
OTELMetricExport(length int)
// OTELMetricExportError is invoked every time the OpenTelemetry Metrics export fails with an error
OTELMetricExportError(err error)
// OTELTraceExport is invoked every time the OpenTelemetry Traces exporter successfully exports traces to
Expand Down
12 changes: 6 additions & 6 deletions pkg/internal/imetrics/iprom.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,20 @@ func (p *PrometheusReporter) Start(ctx context.Context) {
p.beylaInfo.Set(1)
}

func (p *PrometheusReporter) TracerFlush(len int) {
p.tracerFlushes.Observe(float64(len))
func (p *PrometheusReporter) TracerFlush(length int) {
p.tracerFlushes.Observe(float64(length))
}

func (p *PrometheusReporter) OTELMetricExport(len int) {
p.otelMetricExports.Add(float64(len))
func (p *PrometheusReporter) OTELMetricExport(length int) {
p.otelMetricExports.Add(float64(length))
}

func (p *PrometheusReporter) OTELMetricExportError(err error) {
p.otelMetricExportErrs.WithLabelValues(err.Error()).Inc()
}

func (p *PrometheusReporter) OTELTraceExport(len int) {
p.otelTraceExports.Add(float64(len))
func (p *PrometheusReporter) OTELTraceExport(length int) {
p.otelTraceExports.Add(float64(length))
}

func (p *PrometheusReporter) OTELTraceExportError(err error) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/internal/netolly/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import (
"log/slog"
"net"

"github.com/cilium/ebpf/ringbuf"

"github.com/grafana/beyla/v2/pkg/beyla"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/tcmanager"
"github.com/grafana/beyla/v2/pkg/internal/netolly/ebpf"
"github.com/grafana/beyla/v2/pkg/internal/netolly/flow"
Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/netolly/ebpf/sock_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
"unsafe"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/ringbuf"
"github.com/cilium/ebpf/rlimit"
"golang.org/x/sys/unix"

convenience "github.com/grafana/beyla/v2/pkg/internal/ebpf/convenience"
"github.com/grafana/beyla/v2/pkg/internal/ebpf/ringbuf"
)

// $BPF_CLANG and $BPF_CFLAGS are set by the Makefile.
Expand Down
Loading
Loading