Documentation ¶
Index ¶
- type Controller
- func (ctl *Controller) GetPerfEventMap() *ebpf.Map
- func (ctl *Controller) ParseKernStack(stackid uint64) ([]*StackFrame, error)
- func (ctl *Controller) ParseUserStack(stackid uint64) ([]*StackFrame, error)
- func (ctl *Controller) ProcessPerfEvents(data []byte) error
- func (ctl *Controller) Start() error
- func (ctl *Controller) StartRecord(pid int, options ...Option) error
- func (ctl *Controller) Status(pid int) []*Status
- func (ctl *Controller) Stop()
- func (ctl *Controller) StopRecord(pid int) error
- type EventStat
- type LogWriter
- type LogWriterConfig
- type NewRecorderFunc
- type OpType
- type Option
- func WithBlackList(list []string) Option
- func WithClusterName(cluster string) Option
- func WithEventBufSize(size int) Option
- func WithGoVersion(ver int) Option
- func WithHostname(hostname string) Option
- func WithMaxActions(max int) Option
- func WithMaxLogDataLen(max int) Option
- func WithMinEventCount(count int) Option
- func WithNewRecorder(f NewRecorderFunc) Option
- func WithRateLimit(limit float64) Option
- func WithServiceName(service string) Option
- func WithSessionBufSize(size int) Option
- func WithSessionExpire(expire time.Duration) Option
- func WithSessionWriter(writer SessionWriter) Option
- func WithSocketExpire(expire time.Duration) Option
- func WithThreadExpire(expire time.Duration) Option
- type Options
- type RateLimiter
- type RecorderIntf
- type SessionRecorder
- func (rc *SessionRecorder) GetSesion(id uint64) model.Session
- func (rc *SessionRecorder) GetSocket(id uint64) model.Socket
- func (rc *SessionRecorder) GetThread(id uint64) model.Thread
- func (rc *SessionRecorder) RecvPerfEvent(item *event.Item) error
- func (rc *SessionRecorder) Reset(seq uint64) error
- func (rc *SessionRecorder) SetDumpLimit(uri string, limit float64, burst int)
- func (rc *SessionRecorder) Start(seq uint64) error
- func (rc *SessionRecorder) Status() *Status
- func (rc *SessionRecorder) Stop()
- type SessionWriter
- type StackFrame
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller maintains all processes being recorded.
func (*Controller) GetPerfEventMap ¶
func (ctl *Controller) GetPerfEventMap() *ebpf.Map
GetPerfEventMap returns the perf event map for reading data from kernel.
func (*Controller) ParseKernStack ¶
func (ctl *Controller) ParseKernStack(stackid uint64) ([]*StackFrame, error)
ParseKernStack parse kernel stack from the specified stackid.
func (*Controller) ParseUserStack ¶
func (ctl *Controller) ParseUserStack(stackid uint64) ([]*StackFrame, error)
ParseUserStack parse user stack from the specified stackid.
func (*Controller) ProcessPerfEvents ¶
func (ctl *Controller) ProcessPerfEvents(data []byte) error
ProcessPerfEvents parses the tgid from the perf event data and sends the event to the recorder.
func (*Controller) Start ¶
func (ctl *Controller) Start() error
Start loads bpf objects and starts the read loop of perf event.
func (*Controller) StartRecord ¶
func (ctl *Controller) StartRecord(pid int, options ...Option) error
StartRecord starts recording the specified process.
func (*Controller) Status ¶
func (ctl *Controller) Status(pid int) []*Status
Status returns status of the specified process, or all status if pid = 0.
func (*Controller) Stop ¶
func (ctl *Controller) Stop()
Stop stops read loop and all recorders, unloads bpf objects.
func (*Controller) StopRecord ¶
func (ctl *Controller) StopRecord(pid int) error
StopRecord stops recording the specified process.
type EventStat ¶
type EventStat struct { SocketAcceptCnt uint64 SocketConnectCnt uint64 SocketInfoCnt uint64 SocketSendMsgCnt uint64 SocketRecvMsgCnt uint64 SocketCloseCnt uint64 GoNewProcCnt uint64 }
EventStat perf event stat
type LogWriter ¶
type LogWriter struct {
// contains filtered or unexported fields
}
func NewLogWriter ¶
func NewLogWriter(cfg *LogWriterConfig) *LogWriter
type LogWriterConfig ¶
type NewRecorderFunc ¶
type NewRecorderFunc func(*Options, *sync.Pool) RecorderIntf
type Option ¶
type Option func(opts *Options)
Option sets option for recorder
func WithMaxLogDataLen ¶
WithMaxLogDataLen sets MaxLogDataLen
func WithMinEventCount ¶
WithMinEventCount sets MinEventCount
func WithNewRecorder ¶
func WithNewRecorder(f NewRecorderFunc) Option
WithNewRecorder sets NewRecorder
func WithSessionBufSize ¶
WithSessionBufSize sets SessionBufSize
func WithSessionExpire ¶
WithSessionExpire sets SessionExpire
func WithSessionWriter ¶
func WithSessionWriter(writer SessionWriter) Option
WithSessionWriter sets SessionWriter
func WithSocketExpire ¶
WithSocketExpire sets SocketExpire
func WithThreadExpire ¶
WithThreadExpire sets ThreadExpire
type Options ¶
type Options struct { GoVersion int ServiceName string ClusterName string Hostname string MinEventCount int SessionBufSize int EventBufSize int RateLimit float64 BlackList []string MaxActions int SessionExpire time.Duration ThreadExpire time.Duration SocketExpire time.Duration MaxLogDataLen int SessionWriter SessionWriter NewRecorder NewRecorderFunc Protocol string EnableTrace bool }
Options saves options for recorder
func NewDefaultOptions ¶
func NewDefaultOptions() *Options
NewDefaultOptions create a default options.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter limit dump rate by http request uri.
func NewRateLimiter ¶
func NewRateLimiter(limit rate.Limit, burst int) *RateLimiter
NewRateLimiter create a limiter with default rate limit and burst.
func (*RateLimiter) Allow ¶
func (rl *RateLimiter) Allow(request []byte, protocol string) (string, bool)
Allow checks whether the request can be dump
func (*RateLimiter) NotAllow ¶
func (rl *RateLimiter) NotAllow(uri string)
NotAllow sets the specified uri to disallow.
func (*RateLimiter) Reset ¶
func (rl *RateLimiter) Reset(limits map[string]float64)
Reset resets all limiters.
type RecorderIntf ¶
type RecorderIntf interface { Start(seq uint64) error Reset(seq uint64) error Stop() Status() *Status RecvPerfEvent(e *event.Item) error }
func NewSessionRecorder ¶
func NewSessionRecorder(opts *Options, pool *sync.Pool) RecorderIntf
NewSessionRecorder create a recorder
type SessionRecorder ¶
type SessionRecorder struct {
// contains filtered or unexported fields
}
SessionRecorder is responsible for recording the traffic of a single process.
func (*SessionRecorder) GetSesion ¶
func (rc *SessionRecorder) GetSesion(id uint64) model.Session
GetSesion returns the Sesion with the specified id.
func (*SessionRecorder) GetSocket ¶
func (rc *SessionRecorder) GetSocket(id uint64) model.Socket
GetSocket returns the Socket with the specified id.
func (*SessionRecorder) GetThread ¶
func (rc *SessionRecorder) GetThread(id uint64) model.Thread
GetThread returns the Thread with the specified id.
func (*SessionRecorder) RecvPerfEvent ¶
func (rc *SessionRecorder) RecvPerfEvent(item *event.Item) error
RecvPerfEvent is the callback for receiving perf event.
func (*SessionRecorder) Reset ¶
func (rc *SessionRecorder) Reset(seq uint64) error
Reset resets recording
func (*SessionRecorder) SetDumpLimit ¶
func (rc *SessionRecorder) SetDumpLimit(uri string, limit float64, burst int)
SetDumpLimit updates session dump rate for the specified uri.
func (*SessionRecorder) Start ¶
func (rc *SessionRecorder) Start(seq uint64) error
Start sets the first sequence number of perf event, and starts recording.
func (*SessionRecorder) Status ¶
func (rc *SessionRecorder) Status() *Status
Status returns the recorder status.
type SessionWriter ¶
SessionWriter writes sessions to store.
func DefaultSessionWriter ¶
func DefaultSessionWriter() SessionWriter
type StackFrame ¶
StackFrame represents a call frame