model

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package model provides type aliases for backward compatibility. All core analysis types have been migrated to the perflib/model package. This file ensures existing code that imports pkg/model continues to work.

Package model defines output data abstractions for different analysis types. Core analysis types have been migrated to github.com/junjiewwang/perf-analysis/perflib/model. This file retains only the AnalysisMode function that uses fmt (not migrated to avoid breaking the original function signature which differs from perflib's AnalysisModeString).

Package model defines the core data structures used throughout the application.

Index

Constants

View Source
const (
	DataTypeCPUProfiling   = libmodel.DataTypeCPUProfiling
	DataTypeAllocation     = libmodel.DataTypeAllocation
	DataTypeHeapDump       = libmodel.DataTypeHeapDump
	DataTypeMemoryLeak     = libmodel.DataTypeMemoryLeak
	DataTypeTracing        = libmodel.DataTypeTracing
	DataTypePProfCPU       = libmodel.DataTypePProfCPU
	DataTypePProfHeap      = libmodel.DataTypePProfHeap
	DataTypePProfGoroutine = libmodel.DataTypePProfGoroutine
	DataTypePProfBlock     = libmodel.DataTypePProfBlock
	DataTypePProfMutex     = libmodel.DataTypePProfMutex
	DataTypePProfBatch     = libmodel.DataTypePProfBatch
)
View Source
const (
	ProfilerPerf          = libmodel.ProfilerPerf
	ProfilerAsyncProfiler = libmodel.ProfilerAsyncProfiler
	ProfilerPProf         = libmodel.ProfilerPProf
	ProfilerHeapDump      = libmodel.ProfilerHeapDump
	ProfilerJeprof        = libmodel.ProfilerJeprof
)
View Source
const (
	EventCPU       = libmodel.EventCPU
	EventAlloc     = libmodel.EventAlloc
	EventHeap      = libmodel.EventHeap
	EventWall      = libmodel.EventWall
	EventLock      = libmodel.EventLock
	EventGoroutine = libmodel.EventGoroutine
	EventBlock     = libmodel.EventBlock
	EventMutex     = libmodel.EventMutex
	EventIO        = libmodel.EventIO
)
View Source
const (
	ResourceCPU         = libmodel.ResourceCPU
	ResourceMemory      = libmodel.ResourceMemory
	ResourceIO          = libmodel.ResourceIO
	ResourceApp         = libmodel.ResourceApp
	ResourceGoroutine   = libmodel.ResourceGoroutine
	ResourceConcurrency = libmodel.ResourceConcurrency
)

Variables

View Source
var AnalysisModeString = libmodel.AnalysisModeString

AnalysisModeString is a wrapper for the library function.

View Source
var MarshalAnalysisData = libmodel.MarshalAnalysisData

MarshalAnalysisData is a wrapper for the library function.

View Source
var UnmarshalAnalysisData = libmodel.UnmarshalAnalysisData

UnmarshalAnalysisData is a wrapper for the library function.

Functions

func AnalysisMode

func AnalysisMode(profiler Profiler, event EventType) string

AnalysisMode returns the composite mode string "{profiler}-{event}". Deprecated: Use AnalysisModeString instead.

Types

type AllocationData

type AllocationData = libmodel.AllocationData

AllocationData is an alias for the library type.

type AnalysisContext

type AnalysisContext struct {
	ActiveThreadJSON        string         `json:"active_thread_json"`
	CallGraphFile           string         `json:"callgraph_file"`
	ExtendedFlameGraphFile  string         `json:"extended_flamegraph_file"`
	FlameGraphFile          string         `json:"flamegraph_file"`
	Suggestions             []Suggestion   `json:"suggestions"`
	TopFuncs                string         `json:"top_funcs"`
	TopFuncsWithSwapper     string         `json:"top_funcs_with_swapper"`
	TotalRecords            int64          `json:"total_records"`
	TotalRecordsWithSwapper int64          `json:"total_records_with_swapper"`
	TID                     string         `json:"tid"`
	Mode                    string         `json:"mode"`
	Status                  TaskStatus     `json:"status"`
	StatusInfo              string         `json:"status_info"`
	CreateTime              int64          `json:"create_time"`
	BeginTime               int64          `json:"begin_time"`
	EndTime                 int64          `json:"end_time"`
	AnalysisStatus          AnalysisStatus `json:"analysis_status"`
}

AnalysisContext holds the context during analysis.

func NewAnalysisContext

func NewAnalysisContext() *AnalysisContext

NewAnalysisContext creates a new AnalysisContext with default values.

func (*AnalysisContext) SetFromNamespaceResult

func (ctx *AnalysisContext) SetFromNamespaceResult(ns *NamespaceResult)

SetFromNamespaceResult updates context from namespace result.

type AnalysisData

type AnalysisData = libmodel.AnalysisData

AnalysisData is an alias for the library interface.

type AnalysisDataType

type AnalysisDataType = libmodel.AnalysisDataType

AnalysisDataType is an alias for the library type.

type AnalysisRequest

type AnalysisRequest struct {
	TaskID        int64
	TaskUUID      string
	Mode          string
	InputFile     string
	OutputDir     string
	ResultFile    string
	UserName      string
	MasterTaskTID *string
	COSBucket     string
	RequestParams RequestParams
}

AnalysisRequest represents a request to analyze profiling data. This is the business version with task-specific fields. For the library-clean version, use perflib/model.AnalysisRequest.

type AnalysisResponse

type AnalysisResponse struct {
	TaskUUID     string           `json:"task_uuid"`
	Mode         string           `json:"mode"`
	TotalRecords int              `json:"total_records"`
	OutputFiles  []OutputFile     `json:"output_files"`
	Data         AnalysisData     `json:"data"`
	Suggestions  []SuggestionItem `json:"suggestions"`
	Error        string           `json:"error,omitempty"`
}

AnalysisResponse represents the response from an analysis.

type AnalysisResult

type AnalysisResult struct {
	TaskUUID                string                     `json:"tid"`
	ContainersInfo          map[string]ContainerInfo   `json:"containers_info"`
	Result                  map[string]NamespaceResult `json:"result"`
	Version                 string                     `json:"version"`
	TotalRecords            int64                      `json:"total_records"`
	TotalRecordsWithSwapper int64                      `json:"total_records_with_swapper"`
	AnalyzedAt              time.Time                  `json:"analyzed_at"`
}

AnalysisResult represents the result of an analysis task.

type AnalysisStatus

type AnalysisStatus int

AnalysisStatus represents the analysis status.

const (
	AnalysisStatusPending   AnalysisStatus = 0 // Not started
	AnalysisStatusRunning   AnalysisStatus = 1 // Running
	AnalysisStatusCompleted AnalysisStatus = 2 // Completed
	AnalysisStatusFailed    AnalysisStatus = 3 // Failed
	AnalysisStatusEmpty     AnalysisStatus = 5 // Empty data
)

type CPUProfilingData

type CPUProfilingData = libmodel.CPUProfilingData

CPUProfilingData is an alias for the library type.

type CallStackInfo

type CallStackInfo = libmodel.CallStackInfo

CallStackInfo is an alias for the library type.

type ContainerInfo

type ContainerInfo struct {
	ContainerID   string `json:"container_id,omitempty"`
	ContainerName string `json:"container_name,omitempty"`
	PodName       string `json:"pod_name,omitempty"`
	Namespace     string `json:"namespace,omitempty"`
}

ContainerInfo holds container metadata.

type EventType

type EventType = libmodel.EventType

EventType is an alias for the library type.

type GCRootPath

type GCRootPath = libmodel.GCRootPath

GCRootPath is an alias for the library type.

type GCRootPathNode

type GCRootPathNode = libmodel.GCRootPathNode

GCRootPathNode is an alias for the library type.

type GoroutineGroup

type GoroutineGroup = libmodel.GoroutineGroup

GoroutineGroup is an alias for the library type.

type HeapAnalysisData

type HeapAnalysisData = libmodel.HeapAnalysisData

HeapAnalysisData is an alias for the library type.

type HeapBiggestObject

type HeapBiggestObject = libmodel.HeapBiggestObject

HeapBiggestObject is an alias for the library type.

type HeapBusinessRetainer

type HeapBusinessRetainer = libmodel.HeapBusinessRetainer

HeapBusinessRetainer is an alias for the library type.

type HeapClassStats

type HeapClassStats = libmodel.HeapClassStats

HeapClassStats is an alias for the library type.

type HeapGCRootClass

type HeapGCRootClass = libmodel.HeapGCRootClass

HeapGCRootClass is an alias for the library type.

type HeapGCRootInstance

type HeapGCRootInstance = libmodel.HeapGCRootInstance

HeapGCRootInstance is an alias for the library type.

type HeapGCRootPath

type HeapGCRootPath = libmodel.HeapGCRootPath

HeapGCRootPath is an alias for the library type.

type HeapGCRootPathNode

type HeapGCRootPathNode = libmodel.HeapGCRootPathNode

HeapGCRootPathNode is an alias for the library type.

type HeapGCRootsData

type HeapGCRootsData = libmodel.HeapGCRootsData

HeapGCRootsData is an alias for the library type.

type HeapGCRootsSummary

type HeapGCRootsSummary = libmodel.HeapGCRootsSummary

HeapGCRootsSummary is an alias for the library type.

type HeapObjectField

type HeapObjectField = libmodel.HeapObjectField

HeapObjectField is an alias for the library type.

type HeapReferenceEdge

type HeapReferenceEdge = libmodel.HeapReferenceEdge

HeapReferenceEdge is an alias for the library type.

type HeapReferenceGraph

type HeapReferenceGraph = libmodel.HeapReferenceGraph

HeapReferenceGraph is an alias for the library type.

type HeapReferenceNode

type HeapReferenceNode = libmodel.HeapReferenceNode

HeapReferenceNode is an alias for the library type.

type HeapRetainer

type HeapRetainer = libmodel.HeapRetainer

HeapRetainer is an alias for the library type.

type LeakInfo

type LeakInfo = libmodel.LeakInfo

LeakInfo is an alias for the library type.

type MasterTaskSuggestions

type MasterTaskSuggestions struct {
	CPU    []SuggestionGroup `json:"CPU"`
	Memory []SuggestionGroup `json:"Memory"`
	Disk   []SuggestionGroup `json:"Disk"`
	App    []SuggestionGroup `json:"App"`
}

MasterTaskSuggestions holds suggestions grouped by resource type for master tasks.

func NewMasterTaskSuggestions

func NewMasterTaskSuggestions() *MasterTaskSuggestions

NewMasterTaskSuggestions creates a new MasterTaskSuggestions instance.

func (*MasterTaskSuggestions) AddSuggestionGroup

func (m *MasterTaskSuggestions) AddSuggestionGroup(resourceType string, group SuggestionGroup)

AddSuggestionGroup adds a suggestion group to the appropriate resource type.

type MemoryLeakData

type MemoryLeakData = libmodel.MemoryLeakData

MemoryLeakData is an alias for the library type.

type NamespaceResult

type NamespaceResult struct {
	TopFuncs               string          `json:"top_funcs"`
	TopFuncsCallstacks     json.RawMessage `json:"top_funcs_callstacks,omitempty"`
	ActiveThreadsJSON      string          `json:"active_threads_json"`
	FlameGraphFile         string          `json:"flamegraph_file"`
	ExtendedFlameGraphFile string          `json:"extended_flamegraph_file"`
	CallGraphFile          string          `json:"callgraph_file"`
	Suggestions            []Suggestion    `json:"suggestions"`
	TotalRecords           int64           `json:"total_records"`
}

NamespaceResult holds the analysis result for a specific namespace/container.

type OutputFile

type OutputFile = libmodel.OutputFile

OutputFile is an alias for the library type.

type PProfBatchData

type PProfBatchData = libmodel.PProfBatchData

PProfBatchData is an alias for the library type.

type PProfBatchProfileSet

type PProfBatchProfileSet = libmodel.PProfBatchProfileSet

PProfBatchProfileSet is an alias for the library type.

type PProfBlockData

type PProfBlockData = libmodel.PProfBlockData

PProfBlockData is an alias for the library type.

type PProfCPUData

type PProfCPUData = libmodel.PProfCPUData

PProfCPUData is an alias for the library type.

type PProfGoroutineData

type PProfGoroutineData = libmodel.PProfGoroutineData

PProfGoroutineData is an alias for the library type.

type PProfHeapData

type PProfHeapData = libmodel.PProfHeapData

PProfHeapData is an alias for the library type.

type PProfHeapSummary

type PProfHeapSummary = libmodel.PProfHeapSummary

PProfHeapSummary is an alias for the library type.

type PProfLeakGrowthItem

type PProfLeakGrowthItem = libmodel.PProfLeakGrowthItem

PProfLeakGrowthItem is an alias for the library type.

type PProfLeakReport

type PProfLeakReport = libmodel.PProfLeakReport

PProfLeakReport is an alias for the library type.

type PProfLeakReportSummary

type PProfLeakReportSummary = libmodel.PProfLeakReportSummary

PProfLeakReportSummary is an alias for the library type.

type PProfMemoryStats

type PProfMemoryStats = libmodel.PProfMemoryStats

PProfMemoryStats is an alias for the library type.

type PProfTopFunc

type PProfTopFunc = libmodel.PProfTopFunc

PProfTopFunc is an alias for the library type.

type ParseResult

type ParseResult = libmodel.ParseResult

ParseResult is an alias for the library type.

type Profiler

type Profiler = libmodel.Profiler

Profiler is an alias for the library type.

type RequestParams

type RequestParams struct {
	Duration       int    `json:"duration,omitempty"`
	PerfDuration   int    `json:"perf_duration,omitempty"`
	ContainerType  int    `json:"container_type,omitempty"`
	ContainerName  string `json:"container_name,omitempty"`
	AnnotateEnable bool   `json:"annotate_enable,omitempty"`
}

RequestParams holds task request parameters.

func (*RequestParams) UnmarshalJSON

func (rp *RequestParams) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for RequestParams.

type ResourceType

type ResourceType = libmodel.ResourceType

ResourceType is an alias for the library type.

type Sample

type Sample = libmodel.Sample

Sample is an alias for the library type.

type Suggestion

type Suggestion struct {
	ID           int64           `json:"id,omitempty" db:"id"`
	TaskUUID     string          `json:"tid" db:"tid"`
	Namespace    string          `json:"namespace,omitempty" db:"namespace"`
	Type         string          `json:"type,omitempty"`
	Severity     string          `json:"severity,omitempty"`
	Suggestion   string          `json:"suggestion" db:"suggestion"`
	FuncName     string          `json:"func,omitempty" db:"func"`
	CallStack    json.RawMessage `json:"callstack,omitempty" db:"call_stack"`
	AISuggestion string          `json:"ai_suggestion,omitempty" db:"ai_suggestion"`
	CreatedAt    time.Time       `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt    time.Time       `json:"updated_at,omitempty" db:"updated_at"`
}

Suggestion represents an analysis suggestion.

func (*Suggestion) IsEmpty

func (s *Suggestion) IsEmpty() bool

IsEmpty returns true if the suggestion text is empty.

type SuggestionBuilder

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

SuggestionBuilder helps build suggestions with a fluent interface.

func NewSuggestionBuilder

func NewSuggestionBuilder() *SuggestionBuilder

NewSuggestionBuilder creates a new SuggestionBuilder.

func (*SuggestionBuilder) Build

func (b *SuggestionBuilder) Build() Suggestion

Build returns the built Suggestion.

func (*SuggestionBuilder) WithAISuggestion

func (b *SuggestionBuilder) WithAISuggestion(aiSuggestion string) *SuggestionBuilder

WithAISuggestion sets the AI suggestion.

func (*SuggestionBuilder) WithCallStack

func (b *SuggestionBuilder) WithCallStack(callStack interface{}) *SuggestionBuilder

WithCallStack sets the call stack.

func (*SuggestionBuilder) WithFunc

func (b *SuggestionBuilder) WithFunc(funcName string) *SuggestionBuilder

WithFunc sets the function name.

func (*SuggestionBuilder) WithNamespace

func (b *SuggestionBuilder) WithNamespace(namespace string) *SuggestionBuilder

WithNamespace sets the namespace.

func (*SuggestionBuilder) WithSuggestion

func (b *SuggestionBuilder) WithSuggestion(text string) *SuggestionBuilder

WithSuggestion sets the suggestion text.

func (*SuggestionBuilder) WithTaskUUID

func (b *SuggestionBuilder) WithTaskUUID(taskUUID string) *SuggestionBuilder

WithTaskUUID sets the task UUID.

type SuggestionGroup

type SuggestionGroup struct {
	Suggestion []Suggestion `json:"suggestion"`
}

SuggestionGroup represents a group of suggestions from a sub-task.

type SuggestionItem

type SuggestionItem = libmodel.SuggestionItem

SuggestionItem is an alias for the library type.

type SuggestionRule

type SuggestionRule struct {
	ID                int64   `json:"id" db:"id"`
	Type              string  `json:"type" db:"type"`
	Operation         string  `json:"operation" db:"operation"`
	Target            string  `json:"target" db:"target"`
	TargetType        string  `json:"target_type" db:"target_type"`
	Threshold         float64 `json:"threshold" db:"threshold"`
	SuggestionContent string  `json:"suggestion_content" db:"suggestion_content"`
}

SuggestionRule represents an analysis rule for generating suggestions.

type Task

type Task struct {
	ID             int64             `json:"id" db:"id"`
	TaskUUID       string            `json:"tid" db:"tid"`
	Profiler       Profiler          `json:"profiler" db:"profiler"`
	Event          EventType         `json:"event" db:"event"`
	Mode           string            `json:"mode" db:"mode"`
	Status         TaskStatus        `json:"status" db:"status"`
	AnalysisStatus AnalysisStatus    `json:"analysis_status" db:"analysis_status"`
	StatusInfo     string            `json:"status_info" db:"status_info"`
	ResultFile     string            `json:"result_file" db:"result_file"`
	UserName       string            `json:"user_name" db:"user_name"`
	MasterTaskTID  *string           `json:"mastertask_tid" db:"mastertask_tid"`
	COSBucket      string            `json:"cos_bucket" db:"cos_bucket"`
	RequestParams  RequestParams     `json:"request_params" db:"request_params"`
	CallbackURL    string            `json:"callback_url,omitempty" db:"callback_url"`
	Metadata       map[string]string `json:"metadata,omitempty" db:"metadata"`
	CreateTime     time.Time         `json:"create_time" db:"create_time"`
	BeginTime      *time.Time        `json:"begin_time" db:"begin_time"`
	EndTime        *time.Time        `json:"end_time" db:"end_time"`
}

Task represents a profiling task.

func NewTask

func NewTask(id int64, taskUUID string, profiler Profiler, event EventType) *Task

NewTask creates a new Task instance.

func (*Task) IsHighPriority

func (t *Task) IsHighPriority() bool

IsHighPriority returns true if the task should be treated as high priority.

func (*Task) IsMasterTask

func (t *Task) IsMasterTask() bool

IsMasterTask returns true if the task has a master task.

type TaskStatus

type TaskStatus int

TaskStatus represents the status of a task.

const (
	TaskStatusPending   TaskStatus = 0 // Pending
	TaskStatusRunning   TaskStatus = 1 // Running (data collection)
	TaskStatusCompleted TaskStatus = 2 // Completed (data collection done)
	TaskStatusFailed    TaskStatus = 3 // Failed
)

type ThreadInfo

type ThreadInfo = libmodel.ThreadInfo

ThreadInfo is an alias for the library type.

type TopFuncValue

type TopFuncValue = libmodel.TopFuncValue

TopFuncValue is an alias for the library type.

type TopFuncsMap

type TopFuncsMap = libmodel.TopFuncsMap

TopFuncsMap is an alias for the library type.

type TopFunction

type TopFunction = libmodel.TopFunction

TopFunction is an alias for the library type.

type TopItem

type TopItem = libmodel.TopItem

TopItem is an alias for the library type.

type TracingData

type TracingData = libmodel.TracingData

TracingData is an alias for the library type.

Jump to

Keyboard shortcuts

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