Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting/compilation on Darwin environments #1199

Merged
merged 1 commit into from
Sep 26, 2024
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this now be 4, 18? Or does it even matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not matter. It's just dummy stuff to let the linter/unit test compiler pass

}
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
Loading