core: bpf: cleanup logs
Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
This commit is contained in:
parent
8ae18a1dd0
commit
97fd480824
|
@ -121,11 +121,9 @@ func newDropWatch() (*tracing.EventTracingAttr, error) {
|
|||
|
||||
// Start starts the tracer.
|
||||
func (c *dropWatchTracing) Start(ctx context.Context) error {
|
||||
log.Info(logPrefix + "tracer will be starting.")
|
||||
|
||||
b, err := bpf.LoadBpf(bpfutil.ThisBpfOBJ(), nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf(logPrefix+"failed to load bpf: %w", err)
|
||||
return fmt.Errorf("load bpf: %w", err)
|
||||
}
|
||||
defer b.Close()
|
||||
|
||||
|
@ -135,15 +133,12 @@ func (c *dropWatchTracing) Start(ctx context.Context) error {
|
|||
// attach
|
||||
reader, err := b.AttachAndEventPipe(childCtx, "perf_events", 8192)
|
||||
if err != nil {
|
||||
return fmt.Errorf(logPrefix+"failed to attach and event pipe: %w", err)
|
||||
return fmt.Errorf("attach and event pipe: %w", err)
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
// breaker
|
||||
b.WaitDetachByBreaker(childCtx, cancel)
|
||||
|
||||
log.Info(logPrefix + "tracer is waitting for event.")
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-childCtx.Done():
|
||||
|
@ -156,16 +151,14 @@ func (c *dropWatchTracing) Start(ctx context.Context) error {
|
|||
}
|
||||
|
||||
// format
|
||||
tracerTime := time.Now()
|
||||
tracerData := c.formatEvent(&event)
|
||||
|
||||
// ignore
|
||||
if c.ignore(tracerData) {
|
||||
log.Debugf(logPrefix+"ignore dropwatch data: %v", tracerData)
|
||||
continue
|
||||
}
|
||||
|
||||
storage.Save(tracerName, "", tracerTime, tracerData)
|
||||
storage.Save(tracerName, "", time.Now(), tracerData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ func newLACPTracing() (*tracing.EventTracingAttr, error) {
|
|||
func (lacp *lacpTracing) Start(ctx context.Context) (err error) {
|
||||
b, err := bpf.LoadBpf(bpfutil.ThisBpfOBJ(), nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Load lacp err: %w", err)
|
||||
return fmt.Errorf("load bpf: %w", err)
|
||||
}
|
||||
defer b.Close()
|
||||
|
||||
|
@ -67,7 +67,7 @@ func (lacp *lacpTracing) Start(ctx context.Context) (err error) {
|
|||
|
||||
reader, err := b.AttachAndEventPipe(childCtx, "ad_event_map", 8192)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to AttachAndEventPipe, err: %w", err)
|
||||
return fmt.Errorf("attach and event pipe: %w", err)
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
|
|
|
@ -61,11 +61,9 @@ func newMemoryReclaim() (*tracing.EventTracingAttr, error) {
|
|||
|
||||
// Start detect work, load bpf and wait data form perfevent
|
||||
func (c *memoryReclaimTracing) Start(ctx context.Context) error {
|
||||
log.Infof("memory reclaim start.")
|
||||
|
||||
deltath := conf.Get().Tracing.MemoryReclaim.Deltath
|
||||
|
||||
b, err := bpf.LoadBpf(bpfutil.ThisBpfOBJ(), map[string]any{"deltath": deltath})
|
||||
b, err := bpf.LoadBpf(bpfutil.ThisBpfOBJ(), map[string]any{
|
||||
"deltath": conf.Get().Tracing.MemoryReclaim.Deltath,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -133,7 +133,6 @@ func (c *netRecvLatTracing) Start(ctx context.Context) error {
|
|||
}
|
||||
b, err := bpf.LoadBpf(bpfutil.ThisBpfOBJ(), args)
|
||||
if err != nil {
|
||||
log.Infof("failed to LoadBpf, err: %v", err)
|
||||
return err
|
||||
}
|
||||
defer b.Close()
|
||||
|
@ -143,7 +142,6 @@ func (c *netRecvLatTracing) Start(ctx context.Context) error {
|
|||
|
||||
reader, err := b.AttachAndEventPipe(childCtx, "net_recv_lat_event_map", 8192)
|
||||
if err != nil {
|
||||
log.Infof("failed to AttachAndEventPipe, err: %v", err)
|
||||
return err
|
||||
}
|
||||
defer reader.Close()
|
||||
|
|
|
@ -105,7 +105,6 @@ func (c *oomCollector) Update() ([]*metric.Data, error) {
|
|||
func (c *oomCollector) Start(ctx context.Context) error {
|
||||
b, err := bpf.LoadBpf(bpfutil.ThisBpfOBJ(), nil)
|
||||
if err != nil {
|
||||
log.Infof("failed to LoadBpf, err: %v", err)
|
||||
return err
|
||||
}
|
||||
defer b.Close()
|
||||
|
@ -115,7 +114,6 @@ func (c *oomCollector) Start(ctx context.Context) error {
|
|||
|
||||
reader, err := b.AttachAndEventPipe(childCtx, "oom_perf_events", 8192)
|
||||
if err != nil {
|
||||
log.Infof("failed to AttachAndEventPipe, err: %v", err)
|
||||
return err
|
||||
}
|
||||
defer reader.Close()
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
|
||||
"huatuo-bamai/internal/bpf"
|
||||
"huatuo-bamai/internal/conf"
|
||||
"huatuo-bamai/internal/log"
|
||||
"huatuo-bamai/internal/storage"
|
||||
"huatuo-bamai/internal/utils/bpfutil"
|
||||
"huatuo-bamai/internal/utils/symbolutil"
|
||||
|
@ -67,14 +66,11 @@ func newSoftirq() (*tracing.EventTracingAttr, error) {
|
|||
}
|
||||
|
||||
func (c *softirqTracing) Start(ctx context.Context) error {
|
||||
log.Infof("Softirq start")
|
||||
|
||||
softirqThresh := conf.Get().Tracing.Softirq.ThresholdTime
|
||||
|
||||
b, err := bpf.LoadBpf(bpfutil.ThisBpfOBJ(), map[string]any{"softirq_thresh": softirqThresh})
|
||||
if err != nil {
|
||||
log.Infof("failed to LoadBpf, err: %v", err)
|
||||
return err
|
||||
return fmt.Errorf("load bpf: %w", err)
|
||||
}
|
||||
defer b.Close()
|
||||
|
||||
|
@ -83,8 +79,7 @@ func (c *softirqTracing) Start(ctx context.Context) error {
|
|||
|
||||
reader, err := attachIrqAndEventPipe(childCtx, b)
|
||||
if err != nil {
|
||||
log.Infof("failed to attachIrqAndEventPipe, err: %v", err)
|
||||
return err
|
||||
return fmt.Errorf("attach irq and event pipe: %w", err)
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
|
|
|
@ -90,12 +90,12 @@ func (c *memoryHost) Start(ctx context.Context) error {
|
|||
var err error
|
||||
c.bpf, err = bpf.LoadBpf(bpfutil.ThisBpfOBJ(), nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("LoadBpf mmhostbpf.o: %w", err)
|
||||
return fmt.Errorf("load bpf: %w", err)
|
||||
}
|
||||
defer c.bpf.Close()
|
||||
|
||||
if err = c.bpf.Attach(); err != nil {
|
||||
return fmt.Errorf("Attach memory_free_compact.o: %w", err)
|
||||
return fmt.Errorf("attach: %w", err)
|
||||
}
|
||||
|
||||
childCtx, cancel := context.WithCancel(ctx)
|
||||
|
|
|
@ -110,12 +110,12 @@ func (c *memoryCgroup) Start(ctx context.Context) error {
|
|||
var err error
|
||||
c.bpf, err = bpf.LoadBpf(bpfutil.ThisBpfOBJ(), nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("LoadBpf memory_cgroup.o: %w", err)
|
||||
return fmt.Errorf("load bpf: %w", err)
|
||||
}
|
||||
defer c.bpf.Close()
|
||||
|
||||
if err = c.bpf.Attach(); err != nil {
|
||||
return fmt.Errorf("failed to Attach, err: %w", err)
|
||||
return fmt.Errorf("attach: %w", err)
|
||||
}
|
||||
|
||||
childCtx, cancel := context.WithCancel(ctx)
|
||||
|
|
|
@ -47,7 +47,7 @@ func startRunqlatTracerWork(ctx context.Context) error {
|
|||
// load bpf.
|
||||
b, err := bpf.LoadBpf(bpfutil.ThisBpfOBJ(), nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to LoadBpf, err: %w", err)
|
||||
return fmt.Errorf("load bpf: %w", err)
|
||||
}
|
||||
defer b.Close()
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ func (c *EventTracing) Start() error {
|
|||
log.Infof("%s: tracing goroutine exited", c.name)
|
||||
}()
|
||||
|
||||
log.Infof("%s tracing start", c.name)
|
||||
log.Infof("start tracing %s", c.name)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ func (c *EventTracing) doStart() {
|
|||
if err := c.ic.Start(ctx); err != nil &&
|
||||
!(errors.Is(err, types.ErrExitByCancelCtx) ||
|
||||
errors.Is(err, types.ErrDisconnectedHuatuo)) {
|
||||
log.Errorf("start tracing error: %s, %v", c.name, err)
|
||||
log.Errorf("start tracing %s: %v", c.name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue