Documentation
¶
Index ¶
- type CheckContext
- type CheckType
- type Checker
- type ContinuousConfig
- type LatestWindowData
- type MetricsAppender
- type Policy
- type PolicyItem
- type ServicePolicy
- type SyncPolicyWithProcesses
- type TargetProfilingType
- type ThresholdCause
- type TimeWindows
- func (t *TimeWindows[D, R]) Add(tm time.Time, val D)
- func (t *TimeWindows[D, R]) FlushMostRecentData() (R, bool)
- func (t *TimeWindows[D, R]) FlushMultipleRecentData() ([]R, bool)
- func (t *TimeWindows[V, R]) MatchRule(policy *PolicyItem, check func(slot R) bool) (lastMatch R, isMatch bool)
- func (t *TimeWindows[V, R]) ScalePeriod(items []*PolicyItem)
- type Trigger
- type TriggerConfig
- type TriggerReporter
- type URIChecker
- type URIResponseDurationTimeoutRate
- type WindowData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckContext ¶
type CheckContext interface {
// ShouldCheck validate the process with policy item should be checked or ignore
// Usually if the process already start profiling with specific process, the check should be ignored
ShouldCheck(p api.ProcessInterface, item *PolicyItem) bool
}
type Checker ¶
type Checker interface {
// Init the checker with basic configs
Init(config *ContinuousConfig) error
// SyncPolicies from all service policies and processes
SyncPolicies(policies []*SyncPolicyWithProcesses)
// Fetch the policies data and save to the time windows
Fetch() error
// Check the policies are reached
// Each policy with process should use CheckContext.ShouldCheck to validate the policy should be checked or not
Check(ctx CheckContext, metricsAppender *MetricsAppender) []ThresholdCause
// Close the checker
Close() error
}
type ContinuousConfig ¶
type ContinuousConfig struct {
MeterPrefix string `mapstructure:"meter_prefix"` // continuous related meters prefix name
FetchInterval string `mapstructure:"fetch_interval"` // The interval of fetch metrics from the system
CheckInterval string `mapstructure:"check_interval"` // The interval of check metrics is reach the thresholds
Trigger TriggerConfig `mapstructure:"trigger"`
}
type LatestWindowData ¶
type LatestWindowData[D comparable] struct { Value D }
LatestWindowData only save the last data in one slot
func (*LatestWindowData[D]) Accept ¶
func (t *LatestWindowData[D]) Accept(data D)
func (*LatestWindowData[D]) Get ¶
func (t *LatestWindowData[D]) Get() D
func (*LatestWindowData[D]) Reset ¶
func (t *LatestWindowData[D]) Reset()
type MetricsAppender ¶
type MetricsAppender struct {
// contains filtered or unexported fields
}
func NewMetricsAppender ¶
func NewMetricsAppender(prefix string) *MetricsAppender
func (*MetricsAppender) AppendProcessSingleValue ¶
func (m *MetricsAppender) AppendProcessSingleValue(name string, p api.ProcessInterface, labels map[string]string, value float64)
func (*MetricsAppender) Flush ¶
func (m *MetricsAppender) Flush(ctx context.Context, client v3.MeterReportServiceClient) error
type Policy ¶
type Policy struct {
TargetProfilingType TargetProfilingType
Items map[CheckType]*PolicyItem
ServicePolicy *ServicePolicy
}
type PolicyItem ¶
type PolicyItem struct {
Threshold string
Period int
Count int
URIList []string
URIRegex string
Policy *Policy
}
func (*PolicyItem) SameURIFilter ¶
func (p *PolicyItem) SameURIFilter(other *PolicyItem) bool
type ServicePolicy ¶
type SyncPolicyWithProcesses ¶
type SyncPolicyWithProcesses struct {
Policy *Policy
Processes map[string]api.ProcessInterface
}
type TargetProfilingType ¶
type TargetProfilingType string
const ( TargetProfilingTypeOnCPU TargetProfilingType = "ON_CPU" TargetProfilingTypeOffCPU TargetProfilingType = "OFF_CPU" TargetProfilingTypeNetwork TargetProfilingType = "NETWORK" )
type ThresholdCause ¶
type ThresholdCause interface {
// Process is over threshold
Process() api.ProcessInterface
// FromPolicy current from which policy
FromPolicy() *PolicyItem
// GenerateTransferCause transmit to the backend
GenerateTransferCause() *v3.ContinuousProfilingCause
}
type TimeWindows ¶
func NewTimeWindows ¶
func NewTimeWindows[V any, R any](items []*PolicyItem, generator func() WindowData[V, R]) *TimeWindows[V, R]
func (*TimeWindows[D, R]) Add ¶
func (t *TimeWindows[D, R]) Add(tm time.Time, val D)
func (*TimeWindows[D, R]) FlushMostRecentData ¶
func (t *TimeWindows[D, R]) FlushMostRecentData() (R, bool)
func (*TimeWindows[D, R]) FlushMultipleRecentData ¶
func (t *TimeWindows[D, R]) FlushMultipleRecentData() ([]R, bool)
func (*TimeWindows[V, R]) MatchRule ¶
func (t *TimeWindows[V, R]) MatchRule(policy *PolicyItem, check func(slot R) bool) (lastMatch R, isMatch bool)
func (*TimeWindows[V, R]) ScalePeriod ¶
func (t *TimeWindows[V, R]) ScalePeriod(items []*PolicyItem)
type Trigger ¶
type Trigger interface {
// Init trigger
Init(moduleMgr *module.Manager, conf *ContinuousConfig) error
// ShouldTrigger validate the process should be trigger task
ShouldTrigger(p api.ProcessInterface) bool
// TriggerTasks generate task and execute that policy could be trigger
TriggerTasks(reporter TriggerReporter, causes []ThresholdCause) int
}
type TriggerConfig ¶
type TriggerReporter ¶
type TriggerReporter interface {
ReportProcesses(causeProcess api.ProcessInterface, profilingProcesses []api.ProcessInterface, cases []ThresholdCause,
taskSetter func(task *taskBase.ProfilingTask),
reportSetter func(report *v3.ContinuousProfilingReport)) (*task.Context, error)
}
type URIChecker ¶
type WindowData ¶
type WindowData[D any, R any] interface { // Reset the data content Reset() // Accept add data Accept(data D) // Get calculate the result Get() R }
WindowData the slot data under TimeWindows
func NewLatestWindowData ¶
func NewLatestWindowData[D comparable]() WindowData[D, D]
Click to show internal directories.
Click to hide internal directories.