Skip to content

Commit

Permalink
Fix linting/compilation on Darwin environments (#1199)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariomac authored Sep 26, 2024
1 parent fb456f1 commit f9f1c5e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
4 changes: 4 additions & 0 deletions pkg/beyla/os_nonlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ func CheckOSSupport() error {
func CheckOSCapabilities(_ *Config) error {
return nil
}

func KernelVersion() (major, minor int) {
return 5, 17
}
2 changes: 1 addition & 1 deletion pkg/internal/discover/attacher_nolinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ func (ta *TraceAttacher) init() error {

func (ta *TraceAttacher) close() {}

func UnmountBPFFS(pinPath string, log *slog.Logger) {}
func UnmountBPFFS(_ string, _ *slog.Logger) {}
7 changes: 0 additions & 7 deletions pkg/internal/ebpf/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"log/slog"

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

ebpfcommon "github.com/grafana/beyla/pkg/internal/ebpf/common"
"github.com/grafana/beyla/pkg/internal/exec"
Expand Down Expand Up @@ -100,12 +99,6 @@ type UtilityTracer interface {

type ProcessTracerType int

type instrumenter struct {
offsets *goexec.Offsets
exe *link.Executable
closables []io.Closer
}

const (
Go = ProcessTracerType(iota)
Generic
Expand Down
5 changes: 4 additions & 1 deletion pkg/internal/ebpf/tracer_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"github.com/grafana/beyla/pkg/internal/request"
)

type instrumenter struct {
}

// dummy implementations to avoid compilation errors in Darwin.
// The tracer component is only usable in Linux.
func (pt *ProcessTracer) Run(_ context.Context, _ chan<- []request.Span) {}
Expand All @@ -22,7 +25,7 @@ func (pt *ProcessTracer) Init() error {
return nil
}

func BuildPinPath(cfg *beyla.Config) string {
func BuildPinPath(_ *beyla.Config) string {
return ""
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/internal/ebpf/tracer_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"io"
"log/slog"
"os"
"path"
Expand All @@ -18,13 +19,20 @@ import (
"github.com/grafana/beyla/pkg/beyla"
common "github.com/grafana/beyla/pkg/internal/ebpf/common"
"github.com/grafana/beyla/pkg/internal/exec"
"github.com/grafana/beyla/pkg/internal/goexec"
"github.com/grafana/beyla/pkg/internal/request"
)

var loadMux sync.Mutex

func ptlog() *slog.Logger { return slog.With("component", "ebpf.ProcessTracer") }

type instrumenter struct {
offsets *goexec.Offsets
exe *link.Executable
closables []io.Closer
}

func NewProcessTracer(cfg *beyla.Config, tracerType ProcessTracerType, programs []Tracer) *ProcessTracer {
return &ProcessTracer{
Programs: programs,
Expand Down

0 comments on commit f9f1c5e

Please sign in to comment.