model

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOKI       = "loki"
	PROMETHEUS = "prometheus"
	DISK       = "disk"
	INFLUXDB   = "influxdb"
	PYROSCOPE  = "pyroscope"
)

expoter type

View Source
const (
	OffCpu     = "offcpu"
	IrqOff     = "irqoff"
	OnCpu      = "oncpu"
	FutexSnoop = "futexsnoop"
	Syscall    = "syscall"
	OtherEvent = "other_event"
)
View Source
const (
	OffCpuMetricName     = "offcpu_dur_ms"
	FutexMaxUerCountName = "max_futex_user_cnt"
)

for metric

View Source
const (
	Comm       = "comm"
	Pid        = "pid"
	Tid        = "tid"
	StartTime  = "start_ts"
	EndTime    = "end_ts"
	IsSent     = "isSent"
	ThreadName = "threadName"
	TimeStamp  = "ts"
	Tid_W      = "waker_tid"
	Pid_W      = "waker_pid"
	Waker      = "waker"
	Wakee      = "wakee"
	Cpu        = "cpu"
	Prio       = "prio"
	CacheId    = "cache_id"

	WTarget = "wtarget"
	Pid_WT  = "pid_wt"
	Tid_WT  = "tid_wt"

	Target      = "target"
	Pid_T       = "wakee_pid"
	Tid_T       = "wakee_tid"
	IrqOffUs_W  = "wakee_irqoff_us"
	CpuOffUs_W  = "waker_offcpu_us"
	RunqLatUs_W = "waker_runqlat_us"
	Stack_W     = "waker_stack"
	IrqOffUs_T  = "wakee_irqoff_us"
	CpuOffUs_T  = "wakee_offcpu_us"
	RunqLatUs_T = "wakee_runqlat_us"
	Stack_T     = "wakee_stack"
	RunqDurMs   = "rq_dur_ms"

	// for futexsnoop
	UserCnt    = "user_cnt"
	MaxUserCnt = "max_user_cnt"
	LockAddr   = "lock_addr"
	MinDur     = "min_dur"
	MaxDur     = "max_dur"
	DeltaDur   = "delta_dur"
	AvgDur     = "avg_dur"
	LockCnt    = "lock_cnt"
	Stack      = "stack"

	// for syscall
	DurMs = "dur_ms"
	DurUs = "dur_us"
)

for labels

View Source
const (
	ProtoUnknown = 0
	ProtoTcp     = 1
	ProtoUdp     = 2
	ProtoIcmp    = 3
	ProtoRaw     = 4
)
View Source
const (
	CpuEventBlockName = "cpu_event_block"
)
View Source
const (
	CpuEventLabel = "cpuEvents"
)
View Source
const (
	SpyEventFieldMax int = 20
)

Variables

View Source
var (
	ByteOrder = GetByteOrder()
)
View Source
var ValueType_name = map[int32]string{
	0:  "NONE",
	1:  "INT8",
	2:  "INT16",
	3:  "INT32",
	4:  "INT64",
	5:  "UINT8",
	6:  "UINT16",
	7:  "UINT32",
	8:  "UINT64",
	9:  "CHARBUF",
	10: "BYTEBUF",
	11: "FLOAT",
	12: "DOUBLE",
	13: "BOOL",
}
View Source
var ValueType_value = map[string]int32{
	"NONE":    0,
	"INT8":    1,
	"INT16":   2,
	"INT32":   3,
	"INT64":   4,
	"UINT8":   5,
	"UINT16":  6,
	"UINT32":  7,
	"UINT64":  8,
	"CHARBUF": 9,
	"BYTEBUF": 10,
	"FLOAT":   11,
	"DOUBLE":  12,
	"BOOL":    13,
}

Functions

func GetByteOrder

func GetByteOrder() binary.ByteOrder

Types

type AttributeMap

type AttributeMap struct {
	// contains filtered or unexported fields
}

func NewAttributeMap

func NewAttributeMap() *AttributeMap

func NewAttributeMapWithValues

func NewAttributeMapWithValues(values map[string]AttributeValue) *AttributeMap

func (*AttributeMap) AddBoolValue

func (a *AttributeMap) AddBoolValue(key string, value bool)

func (*AttributeMap) AddIntValue

func (a *AttributeMap) AddIntValue(key string, value int64)

func (*AttributeMap) AddStringValue

func (a *AttributeMap) AddStringValue(key string, value string)

func (*AttributeMap) ClearAttributes

func (a *AttributeMap) ClearAttributes()

func (*AttributeMap) Clone

func (a *AttributeMap) Clone() *AttributeMap

func (*AttributeMap) GetBoolValue

func (a *AttributeMap) GetBoolValue(key string) bool

func (*AttributeMap) GetIntValue

func (a *AttributeMap) GetIntValue(key string) int64

func (*AttributeMap) GetStringValue

func (a *AttributeMap) GetStringValue(key string) string

func (*AttributeMap) GetValues

func (a *AttributeMap) GetValues() map[string]AttributeValue

func (*AttributeMap) HasAttribute

func (a *AttributeMap) HasAttribute(key string) bool

func (*AttributeMap) IsEmpty

func (a *AttributeMap) IsEmpty() bool

func (AttributeMap) MarshalJSON

func (a AttributeMap) MarshalJSON() ([]byte, error)

func (*AttributeMap) Merge

func (a *AttributeMap) Merge(other *AttributeMap)

func (*AttributeMap) RemoveAttribute

func (a *AttributeMap) RemoveAttribute(key string)

func (*AttributeMap) ResetValues

func (a *AttributeMap) ResetValues()

ResetValues sets the default value for all elements. Used for implementing sync.Pool.

func (*AttributeMap) Size

func (a *AttributeMap) Size() int

func (*AttributeMap) String

func (a *AttributeMap) String() string

func (*AttributeMap) ToStringMap

func (a *AttributeMap) ToStringMap() map[string]string

func (*AttributeMap) UnmarshalJSON

func (a *AttributeMap) UnmarshalJSON(data []byte) error

func (*AttributeMap) UpdateAddBoolValue

func (a *AttributeMap) UpdateAddBoolValue(key string, value bool)

func (*AttributeMap) UpdateAddIntValue

func (a *AttributeMap) UpdateAddIntValue(key string, value int64)

func (*AttributeMap) UpdateAddStringValue

func (a *AttributeMap) UpdateAddStringValue(key string, value string)

type AttributeValue

type AttributeValue interface {
	Type() AttributeValueType
	ToString() string
	Reset()
}

func NewBoolValue

func NewBoolValue(value bool) AttributeValue

func NewIntValue

func NewIntValue(value int64) AttributeValue

func NewStringValue

func NewStringValue(value string) AttributeValue

type AttributeValueType

type AttributeValueType int
const (
	StringAttributeValueType AttributeValueType = iota
	IntAttributeValueType
	BooleanAttributeValueType
)

type CPUType

type CPUType uint8
const (
	CPUType_ON CPUType = 0
)

func (CPUType) MarshalJSON

func (ct CPUType) MarshalJSON() ([]byte, error)

func (*CPUType) UnmarshalJSON

func (ct *CPUType) UnmarshalJSON(data []byte) error

type CircleQueue

type CircleQueue struct {
	// contains filtered or unexported fields
}

func NewCircleQueue

func NewCircleQueue(length int) *CircleQueue

func (*CircleQueue) Clear

func (s *CircleQueue) Clear()

func (*CircleQueue) GetByIndex

func (s *CircleQueue) GetByIndex(index int) interface{}

func (*CircleQueue) UpdateByIndex

func (s *CircleQueue) UpdateByIndex(index int, val interface{})

type ClassInfo

type ClassInfo struct {
	Name  string // 表示归属对应的detecor
	Event string // 表示对应的事件
}

type CpuEvent

type CpuEvent struct {
	TimeStamp  uint64
	StartTime  uint64
	EndTime    uint64
	Waker      string
	Pid_W      uint32
	Target     string
	Pid_WT     uint32
	WTarget    string
	Pid_T      uint32
	IrqOffUs_W uint32
	CpuOffUs_W uint32
	RunLatUs_W uint32
	Stack_W    string
	IrqOffUs_T uint32
	CpuOffUs_T uint32
	RunLatUs_T uint32
	Stack_T    string
	Log        string
	DurMs      uint32
	RunqDurMs  uint32
}

func (*CpuEvent) EndTimestamp

func (c *CpuEvent) EndTimestamp() uint64

func (*CpuEvent) Kind

func (c *CpuEvent) Kind() TimedEventKind

func (*CpuEvent) StartTimestamp

func (c *CpuEvent) StartTimestamp() uint64

type DataBlock

type DataBlock struct {
	Name      string        `json:"name"`
	Metrics   []*Metric     `json:"metrics"`
	Labels    *AttributeMap `json:"labels"`
	Timestamp uint64        `json:"timestamp"`
}

func NewDataBlock

func NewDataBlock(name string, labels *AttributeMap, timestamp uint64, values ...*Metric) *DataBlock

func (*DataBlock) AddIntMetricWithName

func (d *DataBlock) AddIntMetricWithName(name string, value int64)

func (*DataBlock) AddMetric

func (d *DataBlock) AddMetric(metric *Metric)

func (*DataBlock) Clone

func (d *DataBlock) Clone() *DataBlock

func (*DataBlock) GetMetric

func (d *DataBlock) GetMetric(name string) (*Metric, bool)

func (*DataBlock) RemoveMetric

func (d *DataBlock) RemoveMetric(name string)

func (*DataBlock) Reset

func (d *DataBlock) Reset()

func (DataBlock) String

func (d DataBlock) String() string

func (*DataBlock) UpdateAddIntMetric

func (d *DataBlock) UpdateAddIntMetric(name string, value int64)

UpdateAddIntMetric overwrite the metric with the key of 'name' if existing, or adds the metric if not existing.

type EventData

type EventData struct {
	Task    TaskInfo
	Net     NetInfo
	RawData []uint8
}

type Histogram

type Histogram struct {
	Sum                int64
	Count              uint64
	ExplicitBoundaries []int64
	BucketCounts       []uint64
}

type IP

type IP []uint32

type Int

type Int struct {
	Value int64
}

type KeyValue

type KeyValue struct {
	Key       string
	ValueType ValueType
	Value     []byte
}

func (*KeyValue) GetIntValue

func (kv *KeyValue) GetIntValue() int64

func (*KeyValue) GetKey

func (kv *KeyValue) GetKey() string

func (*KeyValue) GetUintValue

func (kv *KeyValue) GetUintValue() uint64

func (*KeyValue) GetValue

func (kv *KeyValue) GetValue() []byte

func (*KeyValue) GetValueType

func (kv *KeyValue) GetValueType() ValueType

type Metric

type Metric struct {
	Name string
	//	Data can be assigned by:
	//	Int
	//	Histogram
	Data isMetricData
}

func NewHistogramMetric

func NewHistogramMetric(name string, histogram *Histogram) *Metric

func NewIntMetric

func NewIntMetric(name string, value int64) *Metric

func NewMetric

func NewMetric(name string, data isMetricData) *Metric

func (*Metric) Clear

func (i *Metric) Clear()

func (*Metric) Clone

func (i *Metric) Clone() *Metric

func (*Metric) DataType

func (i *Metric) DataType() MetricType

func (*Metric) GetData

func (i *Metric) GetData() isMetricData

func (*Metric) GetHistogram

func (i *Metric) GetHistogram() *Histogram

func (*Metric) GetInt

func (i *Metric) GetInt() *Int

type MetricType

type MetricType int
const (
	IntMetricType MetricType = iota
	HistogramMetricType
	NoneMetricType
)

type NetInfo

type NetInfo struct {
	Proto Protocol
	Sip   IP
	Dip   IP
	Sport uint16
	Dport uint16
}

type Protocol

type Protocol uint32

type Segment

type Segment struct {
	StartTime      uint64       `json:"startTime"`
	EndTime        uint64       `json:"endTime"`
	CpuEvents      []TimedEvent `json:"cpuEvents"`
	IsSend         int
	IndexTimestamp string `json:"indexTimestamp"`
}

func NewSegment

func NewSegment(startTime uint64, endTime uint64) *Segment

func (*Segment) PutTimedEvent

func (s *Segment) PutTimedEvent(event TimedEvent)

func (*Segment) UnmarshalJSON

func (s *Segment) UnmarshalJSON(data []byte) error

type SpyEvent

type SpyEvent struct {
	Name      string
	TimeStamp uint64
	Class     ClassInfo
	Task      TaskInfo
	// UserAttributes 数量
	ParamsCnt      uint16
	UserAttributes [SpyEventFieldMax]KeyValue
}

func (*SpyEvent) GetComm

func (s *SpyEvent) GetComm() string

func (*SpyEvent) GetIntUserAttribute

func (s *SpyEvent) GetIntUserAttribute(key string) int64

func (*SpyEvent) GetPid

func (s *SpyEvent) GetPid() uint32

func (*SpyEvent) GetTid

func (s *SpyEvent) GetTid() uint32

func (*SpyEvent) GetUintUserAttribute

func (s *SpyEvent) GetUintUserAttribute(key string) uint64

func (*SpyEvent) GetUserAttribute

func (s *SpyEvent) GetUserAttribute(key string) *KeyValue

func (*SpyEvent) GetUserAttributes

func (s *SpyEvent) GetUserAttributes() *[SpyEventFieldMax]KeyValue

func (*SpyEvent) SetUserAttribute

func (s *SpyEvent) SetUserAttribute(kv KeyValue) error

func (*SpyEvent) SetUserAttributeWithByteBuf

func (s *SpyEvent) SetUserAttributeWithByteBuf(key string, value []byte)

func (*SpyEvent) SetUserAttributeWithInt32

func (s *SpyEvent) SetUserAttributeWithInt32(key string, value int32)

func (*SpyEvent) SetUserAttributeWithInt64

func (s *SpyEvent) SetUserAttributeWithInt64(key string, value int64)

func (*SpyEvent) SetUserAttributeWithUint32

func (s *SpyEvent) SetUserAttributeWithUint32(key string, value uint32)

func (*SpyEvent) SetUserAttributeWithUint64

func (s *SpyEvent) SetUserAttributeWithUint64(key string, value uint64)

type TaskInfo

type TaskInfo struct {
	Pid           uint32
	Tid           uint32
	Comm          string
	ContainerId   string
	ContainerName string
	NameSpace     string
	Stack         []byte
	Latency       uint32
}

type TimeSegments

type TimeSegments struct {
	Pid        uint32       `json:"pid"`
	Tid        uint32       `json:"tid"`
	ThreadName string       `json:"threadName"`
	BaseTime   uint64       `json:"baseTime"`
	Segments   *CircleQueue `json:"segments"`
}

func (*TimeSegments) UpdateThreadName

func (t *TimeSegments) UpdateThreadName(threadName string)

type TimedEvent

type TimedEvent interface {
	StartTimestamp() uint64
	EndTimestamp() uint64
	Kind() TimedEventKind
}

type TimedEventKind

type TimedEventKind int
const (
	TimedCpuEventKind TimedEventKind = iota
)

type ValueType

type ValueType int32
const (
	ValueType_NONE    ValueType = 0
	ValueType_INT8    ValueType = 1
	ValueType_INT16   ValueType = 2
	ValueType_INT32   ValueType = 3
	ValueType_INT64   ValueType = 4
	ValueType_UINT8   ValueType = 5
	ValueType_UINT16  ValueType = 6
	ValueType_UINT32  ValueType = 7
	ValueType_UINT64  ValueType = 8
	ValueType_CHARBUF ValueType = 9
	ValueType_BYTEBUF ValueType = 10
	ValueType_FLOAT   ValueType = 11
	ValueType_DOUBLE  ValueType = 12
	ValueType_BOOL    ValueType = 13
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL