Skip to content

Commit

Permalink
Revert to using maps
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelroquetto committed Nov 30, 2024
1 parent bd398e9 commit 720fc67
Show file tree
Hide file tree
Showing 10 changed files with 374 additions and 436 deletions.
10 changes: 4 additions & 6 deletions pkg/internal/discover/typer.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,11 @@ func (t *typer) loadAllGoFunctionNames() {
uniqueFunctions := map[string]struct{}{}
t.allGoFunctions = nil
for _, p := range newGoTracersGroup(t.cfg, t.metrics) {
goProbes := p.GoProbes()
for i := range goProbes {
funcProg := &goProbes[i]
for symbolName := range p.GoProbes() {
// avoid duplicating function names
if _, ok := uniqueFunctions[funcProg.SymbolName]; !ok {
uniqueFunctions[funcProg.SymbolName] = struct{}{}
t.allGoFunctions = append(t.allGoFunctions, funcProg.SymbolName)
if _, ok := uniqueFunctions[symbolName]; !ok {
uniqueFunctions[symbolName] = struct{}{}
t.allGoFunctions = append(t.allGoFunctions, symbolName)
}
}
}
Expand Down
115 changes: 52 additions & 63 deletions pkg/internal/ebpf/generictracer/generictracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (p *Tracer) AddCloser(c ...io.Closer) {
p.closers = append(p.closers, c...)
}

func (p *Tracer) GoProbes() []ebpfcommon.ProbeDesc {
func (p *Tracer) GoProbes() map[string][]*ebpfcommon.ProbeDesc {
return nil
}

Expand Down Expand Up @@ -353,71 +353,60 @@ func (p *Tracer) Tracepoints() map[string]ebpfcommon.ProbeDesc {
return nil
}

func (p *Tracer) UProbes() map[string][]ebpfcommon.ProbeDesc {
return map[string][]ebpfcommon.ProbeDesc{
func (p *Tracer) UProbes() map[string]map[string][]*ebpfcommon.ProbeDesc {
return map[string]map[string][]*ebpfcommon.ProbeDesc{
"libssl.so": {
{
SymbolName: "SSL_read",
Required: false,
Start: p.bpfObjects.UprobeSslRead,
End: p.bpfObjects.UretprobeSslRead,
},
{
SymbolName: "SSL_write",
Required: false,
Start: p.bpfObjects.UprobeSslWrite,
End: p.bpfObjects.UretprobeSslWrite,
},
{
SymbolName: "SSL_read_ex",
Required: false,
Start: p.bpfObjects.UprobeSslReadEx,
End: p.bpfObjects.UretprobeSslReadEx,
},
{
SymbolName: "SSL_write_ex",
Required: false,
Start: p.bpfObjects.UprobeSslWriteEx,
End: p.bpfObjects.UretprobeSslWriteEx,
},
{
SymbolName: "SSL_do_handshake",
Required: false,
Start: p.bpfObjects.UprobeSslDoHandshake,
End: p.bpfObjects.UretprobeSslDoHandshake,
},
{
SymbolName: "SSL_shutdown",
Required: false,
Start: p.bpfObjects.UprobeSslShutdown,
},
"SSL_read": {{
Required: false,
Start: p.bpfObjects.UprobeSslRead,
End: p.bpfObjects.UretprobeSslRead,
}},
"SSL_write": {{
Required: false,
Start: p.bpfObjects.UprobeSslWrite,
End: p.bpfObjects.UretprobeSslWrite,
}},
"SSL_read_ex": {{
Required: false,
Start: p.bpfObjects.UprobeSslReadEx,
End: p.bpfObjects.UretprobeSslReadEx,
}},
"SSL_write_ex": {{
Required: false,
Start: p.bpfObjects.UprobeSslWriteEx,
End: p.bpfObjects.UretprobeSslWriteEx,
}},
"SSL_do_handshake": {{
Required: false,
Start: p.bpfObjects.UprobeSslDoHandshake,
End: p.bpfObjects.UretprobeSslDoHandshake,
}},
"SSL_shutdown": {{
Required: false,
Start: p.bpfObjects.UprobeSslShutdown,
}},
},
"node": {
{
SymbolName: "_ZN4node9AsyncWrap13EmitAsyncInitEPNS_11EnvironmentEN2v85LocalINS3_6ObjectEEENS4_INS3_6StringEEEdd",
Required: false,
Start: p.bpfObjects.EmitAsyncInit,
},
{
SymbolName: "_ZN4node13EmitAsyncInitEPN2v87IsolateENS0_5LocalINS0_6ObjectEEENS3_INS0_6StringEEEd",
Required: false,
Start: p.bpfObjects.EmitAsyncInit,
},
{
SymbolName: "_ZN4node13EmitAsyncInitEPN2v87IsolateENS0_5LocalINS0_6ObjectEEEPKcd",
Required: false,
Start: p.bpfObjects.EmitAsyncInit,
},
{
SymbolName: "_ZN4node9AsyncWrap10AsyncResetEN2v85LocalINS1_6ObjectEEEdb",
Required: false,
Start: p.bpfObjects.AsyncReset,
},
{
SymbolName: "_ZN4node9AsyncWrap10AsyncResetERKN2v820FunctionCallbackInfoINS1_5ValueEEE",
Required: false,
Start: p.bpfObjects.AsyncReset,
},
"_ZN4node9AsyncWrap13EmitAsyncInitEPNS_11EnvironmentEN2v85LocalINS3_6ObjectEEENS4_INS3_6StringEEEdd": {{
Required: false,
Start: p.bpfObjects.EmitAsyncInit,
}},
"_ZN4node13EmitAsyncInitEPN2v87IsolateENS0_5LocalINS0_6ObjectEEENS3_INS0_6StringEEEd": {{
Required: false,
Start: p.bpfObjects.EmitAsyncInit,
}},
"_ZN4node13EmitAsyncInitEPN2v87IsolateENS0_5LocalINS0_6ObjectEEEPKcd": {{
Required: false,
Start: p.bpfObjects.EmitAsyncInit,
}},
"_ZN4node9AsyncWrap10AsyncResetEN2v85LocalINS1_6ObjectEEEdb": {{
Required: false,
Start: p.bpfObjects.AsyncReset,
}},
"_ZN4node9AsyncWrap10AsyncResetERKN2v820FunctionCallbackInfoINS1_5ValueEEE": {{
Required: false,
Start: p.bpfObjects.AsyncReset,
}},
},
}
}
Expand Down
44 changes: 22 additions & 22 deletions pkg/internal/ebpf/generictracer/generictracer_notlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ import (

type Tracer struct{}

func New(_ *beyla.Config, _ imetrics.Reporter) *Tracer { return nil }
func (p *Tracer) AllowPID(_, _ uint32, _ *svc.Attrs) {}
func (p *Tracer) BlockPID(_, _ uint32) {}
func (p *Tracer) Load() (*ebpf.CollectionSpec, error) { return nil, nil }
func (p *Tracer) BpfObjects() any { return nil }
func (p *Tracer) AddCloser(_ ...io.Closer) {}
func (p *Tracer) GoProbes() []ebpfcommon.ProbeDesc { return nil }
func (p *Tracer) KProbes() map[string]ebpfcommon.ProbeDesc { return nil }
func (p *Tracer) UProbes() map[string][]ebpfcommon.ProbeDesc { return nil }
func (p *Tracer) Tracepoints() map[string]ebpfcommon.ProbeDesc { return nil }
func (p *Tracer) SocketFilters() []*ebpf.Program { return nil }
func (p *Tracer) SockMsgs() []ebpfcommon.SockMsg { return nil }
func (p *Tracer) SockOps() []ebpfcommon.SockOps { return nil }
func (p *Tracer) RecordInstrumentedLib(_ uint64, _ []io.Closer) {}
func (p *Tracer) AddInstrumentedLibRef(_ uint64) {}
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) {}
func New(_ *beyla.Config, _ imetrics.Reporter) *Tracer { return nil }
func (p *Tracer) AllowPID(_, _ uint32, _ *svc.Attrs) {}
func (p *Tracer) BlockPID(_, _ uint32) {}
func (p *Tracer) Load() (*ebpf.CollectionSpec, error) { return nil, nil }
func (p *Tracer) BpfObjects() any { return nil }
func (p *Tracer) AddCloser(_ ...io.Closer) {}
func (p *Tracer) GoProbes() map[string][]*ebpfcommon.ProbeDesc { return nil }
func (p *Tracer) KProbes() map[string]ebpfcommon.ProbeDesc { return nil }
func (p *Tracer) UProbes() map[string]map[string][]*ebpfcommon.ProbeDesc { return nil }
func (p *Tracer) Tracepoints() map[string]ebpfcommon.ProbeDesc { return nil }
func (p *Tracer) SocketFilters() []*ebpf.Program { return nil }
func (p *Tracer) SockMsgs() []ebpfcommon.SockMsg { return nil }
func (p *Tracer) SockOps() []ebpfcommon.SockOps { return nil }
func (p *Tracer) RecordInstrumentedLib(_ uint64, _ []io.Closer) {}
func (p *Tracer) AddInstrumentedLibRef(_ uint64) {}
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) {}
Loading

0 comments on commit 720fc67

Please sign in to comment.