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

WIP: Add TCX support #1478

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions pkg/beyla/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/grafana/beyla/pkg/export/instrumentations"
"github.com/grafana/beyla/pkg/export/otel"
"github.com/grafana/beyla/pkg/export/prom"
"github.com/grafana/beyla/pkg/internal/ebpf/tcmanager"
"github.com/grafana/beyla/pkg/internal/filter"
"github.com/grafana/beyla/pkg/internal/imetrics"
"github.com/grafana/beyla/pkg/internal/infraolly/process"
Expand Down Expand Up @@ -48,6 +49,7 @@ var DefaultConfig = Config{
BatchLength: 100,
BatchTimeout: time.Second,
HTTPRequestTimeout: 30 * time.Second,
TCBackend: tcmanager.TCBackendTC,
},
Grafana: otel.GrafanaConfig{
OTLP: otel.GrafanaOTLP{
Expand Down Expand Up @@ -243,6 +245,10 @@ func (c *Config) Validate() error {
if c.EBPF.BatchLength == 0 {
return ConfigError("BEYLA_BPF_BATCH_LENGTH must be at least 1")
}
if !c.EBPF.TCBackend.Valid() {
return ConfigError("Invalid BEYLA_BPF_TC_BACKEND value")
}

if c.Attributes.Kubernetes.InformersSyncTimeout == 0 {
return ConfigError("BEYLA_KUBE_INFORMERS_SYNC_TIMEOUT duration must be greater than 0s")
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/beyla/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/grafana/beyla/pkg/export/instrumentations"
"github.com/grafana/beyla/pkg/export/otel"
"github.com/grafana/beyla/pkg/export/prom"
"github.com/grafana/beyla/pkg/internal/ebpf/tcmanager"
"github.com/grafana/beyla/pkg/internal/imetrics"
"github.com/grafana/beyla/pkg/internal/infraolly/process"
"github.com/grafana/beyla/pkg/internal/kube"
Expand Down Expand Up @@ -124,6 +125,7 @@ network:
BatchLength: 100,
BatchTimeout: time.Second,
HTTPRequestTimeout: 30 * time.Second,
TCBackend: tcmanager.TCBackendTC,
},
Grafana: otel.GrafanaConfig{
OTLP: otel.GrafanaOTLP{
Expand Down
10 changes: 9 additions & 1 deletion pkg/config/ebpf_tracer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package config

import "time"
import (
"time"

"github.com/grafana/beyla/pkg/internal/ebpf/tcmanager"
)

// EBPFTracer configuration for eBPF programs
type EBPFTracer struct {
Expand Down Expand Up @@ -31,6 +35,10 @@ type EBPFTracer struct {
// Enables Linux Traffic Control probes for context propagation
UseTCForL7CP bool `yaml:"traffic_control_l7_context_propagation" env:"BEYLA_BPF_TC_L7_CP"`

// Select the TC attachment backend: accepted values are 'tc' (netlink),
// and 'tcx'
TCBackend tcmanager.TCBackend `yaml:"traffic_control_backend" env:"BEYLA_BPF_TC_BACKEND"`

// Disables Beyla black-box context propagation. Used for testing purposes only.
DisableBlackBoxCP bool `yaml:"disable_black_box_cp" env:"BEYLA_BPF_DISABLE_BLACK_BOX_CP"`

Expand Down
10 changes: 0 additions & 10 deletions pkg/internal/ebpf/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ var IntegrityModeOverride = false

var ActiveNamespaces = make(map[uint32]uint32)

// These represent unique traffic control (tc) handles to be supplied as
// arguments to RegisterIngress, RegisterEgress or RegisterTC. They all start
// from the 0xb310 offset in simplistic attempt to avoid collisions with
// 3rdparty handles.
const (
NetollyTCHandle = 0xb310 + iota
HTTPTracerTCHandle
TCTracerTCHandle
)

// ProbeDesc holds the information of the instrumentation points of a given
// function/symbol
type ProbeDesc struct {
Expand Down
244 changes: 0 additions & 244 deletions pkg/internal/ebpf/common/tc_linux.go

This file was deleted.

3 changes: 0 additions & 3 deletions pkg/internal/ebpf/generictracer/generictracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,6 @@ func (p *Tracer) AlreadyInstrumentedLib(id uint64) bool {
return module != nil
}

func (p *Tracer) SetupTC() {
}

func (p *Tracer) Run(ctx context.Context, eventsChan chan<- []request.Span) {
// At this point we now have loaded the bpf objects, which means we should insert any
// pids that are allowed into the bpf map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ func (p *Tracer) UnlinkInstrumentedLib(_ uint64) {}
func (p *Tracer) AlreadyInstrumentedLib(_ uint64) bool { return false }
func (p *Tracer) Run(_ context.Context, _ chan<- []request.Span) {}
func (p *Tracer) Constants() map[string]any { return nil }
func (p *Tracer) SetupTC() {}
func (p *Tracer) SetupTailCalls() {}
func (p *Tracer) RegisterOffsets(_ *exec.FileInfo, _ *goexec.Offsets) {}
2 changes: 0 additions & 2 deletions pkg/internal/ebpf/gotracer/gotracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,6 @@ func (p *Tracer) AlreadyInstrumentedLib(_ uint64) bool {
return false
}

func (p *Tracer) SetupTC() {}

func (p *Tracer) Run(ctx context.Context, eventsChan chan<- []request.Span) {
ebpfcommon.SharedRingbuf(
p.cfg,
Expand Down
Loading
Loading