profiling

package
v0.0.0-...-0119d12 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Timeout = 5 * time.Second
)

Variables

View Source
var (
	ErrNS                         = errorx.NewNamespace("error.api.profiling")
	ErrIgnoredRequest             = ErrNS.NewType("ignored_request")
	ErrTimeout                    = ErrNS.NewType("timeout")
	ErrUnsupportedProfilingType   = ErrNS.NewType("unsupported_profiling_type")
	ErrUnsupportedProfilingTarget = ErrNS.NewType("unsupported_profiling_target")
)
View Source
var Module = fx.Options(newFetchers, newService)

Functions

func RegisterRouter

func RegisterRouter(r *gin.RouterGroup, auth *user.AuthService, s *Service)

Register register the handlers to the service.

Types

type GroupDetailResponse

type GroupDetailResponse struct {
	ServerTime int64          `json:"server_time"`
	TaskGroup  TaskGroupModel `json:"task_group_status"`
	Tasks      []TaskModel    `json:"tasks_status"`
}

type Service

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

type ServiceParams

type ServiceParams struct {
	fx.In
	ConfigManager *config.DynamicConfigManager
	LocalStore    *dbstore.DB

	HTTPClient *httpc.Client
	EtcdClient *clientv3.Client
	PDClient   *pd.Client
}

type StartRequest

type StartRequest struct {
	Targets                []model.RequestTargetNode `json:"targets"`
	DurationSecs           uint                      `json:"duration_secs"`
	RequstedProfilingTypes TaskProfilingTypeList     `json:"requsted_profiling_types"`
}

type StartRequestSession

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

type Task

type Task struct {
	*TaskModel
	// contains filtered or unexported fields
}

Task is the unit to fetch profiling information.

func NewTask

func NewTask(ctx context.Context, taskGroup *TaskGroup, target model.RequestTargetNode, fts *fetchers, profilingType TaskProfilingType) *Task

NewTask creates a new profiling task.

type TaskGroup

type TaskGroup struct {
	*TaskGroupModel
	// contains filtered or unexported fields
}

TaskGroup is the collection of tasks.

func NewTaskGroup

func NewTaskGroup(db *dbstore.DB, profileDurationSecs uint, stats model.RequestTargetStatistics, requestedProfilingTypes TaskProfilingTypeList) *TaskGroup

NewTaskGroup create a new profiling task group.

type TaskGroupModel

type TaskGroupModel struct {
	ID                     uint                          `json:"id" gorm:"primary_key"`
	State                  TaskState                     `json:"state" gorm:"index"`
	ProfileDurationSecs    uint                          `json:"profile_duration_secs"`
	TargetStats            model.RequestTargetStatistics `json:"target_stats" gorm:"embedded;embedded_prefix:target_stats_"`
	StartedAt              int64                         `json:"started_at"`
	RequstedProfilingTypes TaskProfilingTypeList         `json:"requsted_profiling_types"`
}

func (TaskGroupModel) TableName

func (TaskGroupModel) TableName() string

type TaskModel

type TaskModel struct {
	ID            uint                    `json:"id" gorm:"primary_key"`
	TaskGroupID   uint                    `json:"task_group_id" gorm:"index"`
	State         TaskState               `json:"state" gorm:"index"`
	Target        model.RequestTargetNode `json:"target" gorm:"embedded;embedded_prefix:target_"`
	FilePath      string                  `json:"-" gorm:"type:text"`
	Error         string                  `json:"error" gorm:"type:text"`
	StartedAt     int64                   `json:"started_at"` // The start running time, reset when retry. Used to estimate approximate profiling progress.
	RawDataType   TaskRawDataType         `json:"raw_data_type" gorm:"raw_data_type"`
	ProfilingType TaskProfilingType       `json:"profiling_type"`
}

func (TaskModel) TableName

func (TaskModel) TableName() string

type TaskProfilingType

type TaskProfilingType string
const (
	ProfilingTypeCPU       TaskProfilingType = "cpu"
	ProfilingTypeHeap      TaskProfilingType = "heap"
	ProfilingTypeGoroutine TaskProfilingType = "goroutine"
	ProfilingTypeMutex     TaskProfilingType = "mutex"
)

type TaskProfilingTypeList

type TaskProfilingTypeList []TaskProfilingType

func (*TaskProfilingTypeList) Scan

func (r *TaskProfilingTypeList) Scan(src interface{}) error

func (TaskProfilingTypeList) Value

func (r TaskProfilingTypeList) Value() (driver.Value, error)

type TaskRawDataType

type TaskRawDataType string
const (
	RawDataTypeJeprof   TaskRawDataType = "jeprof"
	RawDataTypeProtobuf TaskRawDataType = "protobuf"
	RawDataTypeText     TaskRawDataType = "text"
)

type TaskState

type TaskState int

TaskState is used to represent the task/task group state.

const (
	TaskStateError TaskState = iota
	TaskStateRunning
	TaskStateFinish
	TaskStatePartialFinish // Only valid for task group
	TaskStateSkipped
)

Built-in task state.

type ViewOutputType

type ViewOutputType string
const (
	ViewOutputTypeProtobuf ViewOutputType = "protobuf"
	ViewOutputTypeGraph    ViewOutputType = "graph"
	ViewOutputTypeText     ViewOutputType = "text"
)

Jump to

Keyboard shortcuts

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