cpuanalyzer

package
v0.0.0-...-51da36d Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CpuEventLabel           = "cpuEvents"
	JavaFutexEventLabel     = "javaFutexEvents"
	TransactionIdEventLabel = "transactionIds"
	SpanLabel               = "spans"
	InnerCallLabel          = "innerCalls"
)
View Source
const (
	CpuProfile analyzer.Type = "cpuanalyzer"
)

Variables

This section is empty.

Functions

func NewCpuAnalyzer

func NewCpuAnalyzer(cfg interface{}, telemetry *component.TelemetryTools, consumers []consumer.Consumer) analyzer.Analyzer

func ReceiveDataGroupAsSignal

func ReceiveDataGroupAsSignal(data *model.DataGroup)

ReceiveDataGroupAsSignal receives model.DataGroup as a signal. Signal is used to trigger to send CPU on/off events

Types

type ApmSpanEvent

type ApmSpanEvent struct {
	StartTime uint64 `json:"startTime"`
	EndTime   uint64 `json:"endTime"`
	TraceId   string `json:"traceId"`
	Name      string `json:"name"`
}

func (*ApmSpanEvent) EndTimestamp

func (j *ApmSpanEvent) EndTimestamp() uint64

func (*ApmSpanEvent) Kind

func (j *ApmSpanEvent) Kind() TimedEventKind

func (*ApmSpanEvent) StartTimestamp

func (j *ApmSpanEvent) StartTimestamp() uint64

type CPUType

type CPUType uint8
const (
	CPUType_ON    CPUType = 0
	CPUType_FILE  CPUType = 1
	CPUType_NET   CPUType = 2
	CPUType_FUTEX CPUType = 3
	CPUType_IDLE  CPUType = 4
	CPUType_OTHER CPUType = 5
	CPUType_EPOLL CPUType = 6
	CPUTYPE_MAX   CPUType = 7
)

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 Config

type Config struct {
	// SamplingInterval is the sampling interval for the same url.
	// The unit is seconds.
	SamplingInterval int `mapstructure:"sampling_interval"`
	// OpenJavaTraceSampling a switch for whether to use Java-Trace to trigger sampling.
	// The default is false.
	OpenJavaTraceSampling bool `mapstructure:"open_java_trace_sampling"`
	//JavaTraceSlowTime is used to identify the threshold of slow requests recognized by the apm side
	// The unit is seconds.
	JavaTraceSlowTime int `mapstructure:"java_trace_slow_time"`
	// SegmentSize defines how many segments(seconds) can be cached to wait for sending.
	// The elder segments will be overwritten by the newer ones, so don't set it too low.
	SegmentSize int `mapstructure:"segment_size"`
	// EdgeEventsWindowSize is the size of the duration window that seats the edge events.
	// The unit is seconds. The greater it is, the more data will be stored.
	EdgeEventsWindowSize int `mapstructure:"edge_events_window_size"`
	// JavaTraceDeleteInterval is the interval for cleaning up expired data in javatraces.
	// The unit is seconds.
	JavaTraceDeleteInterval int `mapstructure:"java_trace_delete_interval"`
	// JavaTraceExpirationTime is the expiration time for data in javatraces.
	// The unit is seconds.
	JavaTraceExpirationTime int `mapstructure:"java_trace_expiration_time"`
}

func NewDefaultConfig

func NewDefaultConfig() *Config

type CpuAnalyzer

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

func (*CpuAnalyzer) ConsumableEvents

func (ca *CpuAnalyzer) ConsumableEvents() []string

func (*CpuAnalyzer) ConsumeCpuEvent

func (ca *CpuAnalyzer) ConsumeCpuEvent(event *model.KindlingEvent)

func (*CpuAnalyzer) ConsumeEvent

func (ca *CpuAnalyzer) ConsumeEvent(event *model.KindlingEvent) error

func (*CpuAnalyzer) ConsumeJavaFutexEvent

func (ca *CpuAnalyzer) ConsumeJavaFutexEvent(event *model.KindlingEvent)

func (*CpuAnalyzer) ConsumeSpanEvent

func (ca *CpuAnalyzer) ConsumeSpanEvent(event *model.KindlingEvent)

func (*CpuAnalyzer) ConsumeTraces

func (ca *CpuAnalyzer) ConsumeTraces(trace *model.DataGroup)

func (*CpuAnalyzer) ConsumeTransactionIdEvent

func (ca *CpuAnalyzer) ConsumeTransactionIdEvent(event *model.KindlingEvent)

func (*CpuAnalyzer) JavaTraceDelete

func (ca *CpuAnalyzer) JavaTraceDelete(interval time.Duration, expiredDuration time.Duration)

func (*CpuAnalyzer) ProfileModule

func (ca *CpuAnalyzer) ProfileModule() (submodule string, start func() error, stop func() error)

func (*CpuAnalyzer) PutEventToSegments

func (ca *CpuAnalyzer) PutEventToSegments(pid uint32, tid uint32, threadName string, event TimedEvent)

func (*CpuAnalyzer) ReadTraceChan

func (ca *CpuAnalyzer) ReadTraceChan()

ReadTraceChan reads the trace channel and make cpuanalyzer consume them as general events.

func (*CpuAnalyzer) ReadTriggerEventChan

func (ca *CpuAnalyzer) ReadTriggerEventChan()

ReadTriggerEventChan reads the triggerEvent channel and creates tasks to send cpuEvents.

func (*CpuAnalyzer) Shutdown

func (ca *CpuAnalyzer) Shutdown() error

func (*CpuAnalyzer) Start

func (ca *CpuAnalyzer) Start() error

func (*CpuAnalyzer) StartProfile

func (ca *CpuAnalyzer) StartProfile() error

func (*CpuAnalyzer) StopProfile

func (ca *CpuAnalyzer) StopProfile() error

func (*CpuAnalyzer) TidDelete

func (ca *CpuAnalyzer) TidDelete(interval time.Duration, expiredDuration time.Duration)

func (*CpuAnalyzer) Type

func (ca *CpuAnalyzer) Type() analyzer.Type

type CpuEvent

type CpuEvent struct {
	StartTime   uint64    `json:"startTime"`
	EndTime     uint64    `json:"endTime"`
	TypeSpecs   []uint64  `json:"typeSpecs"`
	RunqLatency []uint64  `json:"runqLatency"`
	TimeType    []CPUType `json:"timeType"`
	OnInfo      string    `json:"onInfo"`
	OffInfo     string    `json:"offInfo"`
	Log         string    `json:"log"`
	Stack       string    `json:"stack"`
}

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 InnerCall

type InnerCall struct {
	StartTime uint64           `json:"startTime"`
	EndTime   uint64           `json:"endTime"`
	Trace     *model.DataGroup `json:"trace"`
}

func (*InnerCall) EndTimestamp

func (c *InnerCall) EndTimestamp() uint64

func (*InnerCall) Kind

func (c *InnerCall) Kind() TimedEventKind

func (*InnerCall) StartTimestamp

func (c *InnerCall) StartTimestamp() uint64

type JavaFutexEvent

type JavaFutexEvent struct {
	StartTime uint64 `json:"startTime"`
	EndTime   uint64 `json:"endTime"`
	DataVal   string `json:"dataValue"`
}

func (*JavaFutexEvent) EndTimestamp

func (j *JavaFutexEvent) EndTimestamp() uint64

func (*JavaFutexEvent) Kind

func (j *JavaFutexEvent) Kind() TimedEventKind

func (*JavaFutexEvent) StartTimestamp

func (j *JavaFutexEvent) StartTimestamp() uint64

type ScheduledTask

type ScheduledTask interface {
	// contains filtered or unexported methods
}

type ScheduledTaskRoutine

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

func NewAndStartScheduledTaskRoutine

func NewAndStartScheduledTaskRoutine(
	tickerDuration time.Duration,
	expiredDuration time.Duration,
	task ScheduledTask,
	expiredCallback func()) *ScheduledTaskRoutine

NewAndStartScheduledTaskRoutine creates a new routine and start it immediately.

func (*ScheduledTaskRoutine) Start

func (s *ScheduledTaskRoutine) Start() error

func (*ScheduledTaskRoutine) Stop

func (s *ScheduledTaskRoutine) Stop() error

type Segment

type Segment struct {
	StartTime       uint64       `json:"startTime"`
	EndTime         uint64       `json:"endTime"`
	CpuEvents       []TimedEvent `json:"cpuEvents"`
	JavaFutexEvents []TimedEvent `json:"javaFutexEvents"`
	TransactionIds  []TimedEvent `json:"transactionIds"`
	Spans           []TimedEvent `json:"spans"`
	InnerCalls      []TimedEvent `json:"innerCalls"`
	IsSend          int
	IndexTimestamp  string `json:"indexTimestamp"`
}

func (*Segment) UnmarshalJSON

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

type SendEventsTask

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

type SendTriggerEvent

type SendTriggerEvent struct {
	Pid          uint32           `json:"pid"`
	StartTime    uint64           `json:"startTime"`
	SpendTime    uint64           `json:"spendTime"`
	OriginalData *model.DataGroup `json:"originalData"`
}

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"`
}

type TimedEvent

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

type TimedEventKind

type TimedEventKind int
const (
	TimedCpuEventKind TimedEventKind = iota
	TimedJavaFutexEventKind
	TimedTransactionIdEventKind
	TimedApmSpanEventKind
	TimedInnerCallEventKind
)

type TransactionIdEvent

type TransactionIdEvent struct {
	Timestamp   uint64 `json:"timestamp"`
	TraceId     string `json:"traceId"`
	IsEntry     uint32 `json:"isEntry"`
	Protocol    string `json:"protocol"`
	Url         string `json:"url"`
	PidString   string `json:"pidString"`
	ContainerId string `json:"containerId"`
}

func (*TransactionIdEvent) EndTimestamp

func (t *TransactionIdEvent) EndTimestamp() uint64

func (*TransactionIdEvent) Kind

func (*TransactionIdEvent) StartTimestamp

func (t *TransactionIdEvent) StartTimestamp() uint64

Jump to

Keyboard shortcuts

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