profiling

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalysisResult

type AnalysisResult struct {
	Timestamp       time.Time
	Bottlenecks     []Bottleneck
	Summary         string
	Metrics         *RuntimeMetrics
	Recommendations []string
}

AnalysisResult contains the complete analysis results

type Bottleneck

type Bottleneck struct {
	Type        BottleneckType
	Severity    string // "critical", "high", "medium", "low"
	Component   string
	Description string
	Impact      float64 // Percentage impact on performance
	Suggestions []string
	Details     map[string]interface{}
}

Bottleneck represents a detected performance bottleneck

type BottleneckAnalyzer

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

BottleneckAnalyzer analyzes profiles to identify bottlenecks

func NewBottleneckAnalyzer

func NewBottleneckAnalyzer(profileDir string, logger *zap.Logger) *BottleneckAnalyzer

NewBottleneckAnalyzer creates a new bottleneck analyzer

func (*BottleneckAnalyzer) Analyze

func (b *BottleneckAnalyzer) Analyze(metrics *RuntimeMetrics) (*AnalysisResult, error)

Analyze performs comprehensive bottleneck analysis

type BottleneckType

type BottleneckType string

BottleneckType represents the type of bottleneck detected

const (
	CPUBottleneck         BottleneckType = "cpu"
	MemoryBottleneck      BottleneckType = "memory"
	IOBottleneck          BottleneckType = "io"
	ConcurrencyBottleneck BottleneckType = "concurrency"
	GCBottleneck          BottleneckType = "gc"
)

type ChannelMetrics

type ChannelMetrics struct {
	BufferSize     int
	MaxUtilization int
	AvgUtilization float64
	BlockedTime    time.Duration
	// contains filtered or unexported fields
}

ChannelMetrics tracks channel utilization

type ConnectorMetrics

type ConnectorMetrics struct {
	Name             string
	Type             string
	RecordsProcessed int64
	BytesProcessed   int64
	Errors           int64
	ConnectionTime   time.Duration
	TotalTime        time.Duration
	BatchCount       int64
	AvgBatchSize     float64
}

ConnectorMetrics tracks connector-specific metrics

type MetricsSample

type MetricsSample struct {
	Timestamp     time.Time
	AllocBytes    uint64
	NumGoroutines int
	GCPauseNs     uint64
}

MetricsSample represents a point-in-time metrics sample

type PipelineProfiler

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

PipelineProfiler profiles pipeline performance with detailed metrics

func NewPipelineProfiler

func NewPipelineProfiler(profileConfig *ProfileConfig) *PipelineProfiler

NewPipelineProfiler creates a new pipeline profiler

func (*PipelineProfiler) ProfileDestination

func (p *PipelineProfiler) ProfileDestination(dest core.Destination) core.Destination

ProfileDestination profiles a destination connector

func (*PipelineProfiler) ProfileSource

func (p *PipelineProfiler) ProfileSource(source core.Source) core.Source

ProfileSource profiles a source connector

func (*PipelineProfiler) RecordChannelUtilization

func (p *PipelineProfiler) RecordChannelUtilization(current, capacity int)

RecordChannelUtilization records channel buffer utilization

func (*PipelineProfiler) RecordError

func (p *PipelineProfiler) RecordError()

RecordError increments error counter

func (*PipelineProfiler) RecordRecord

func (p *PipelineProfiler) RecordRecord(bytes int64)

RecordRecord increments record counter

func (*PipelineProfiler) RecordStageMetrics

func (p *PipelineProfiler) RecordStageMetrics(stageName string, recordsIn, recordsOut int64, processingTime time.Duration)

RecordStageMetrics records metrics for a pipeline stage

func (*PipelineProfiler) Start

func (p *PipelineProfiler) Start(ctx context.Context) error

Start begins profiling

func (*PipelineProfiler) Stop

func (p *PipelineProfiler) Stop() (*ProfileResult, error)

Stop stops profiling and generates report

type ProfileConfig

type ProfileConfig struct {
	// Profile types to collect
	Types []ProfileType

	// Output directory for profile files
	OutputDir string

	// Duration for CPU profiling
	CPUDuration time.Duration

	// Memory profile rate (0 = default rate)
	MemProfileRate int

	// Block profile rate (0-100, 0 = disabled)
	BlockProfileRate int

	// Mutex profile fraction (0-100, 0 = disabled)
	MutexProfileFraction int

	// Whether to collect runtime metrics
	CollectRuntimeMetrics bool

	// Sampling interval for runtime metrics
	MetricsSamplingInterval time.Duration

	// Whether to generate flame graphs
	GenerateFlameGraphs bool
}

ProfileConfig contains configuration for profiling

func DefaultProfileConfig

func DefaultProfileConfig() *ProfileConfig

DefaultProfileConfig returns a default profiling configuration

type ProfileResult

type ProfileResult struct {
	// Overall metrics
	Duration       time.Duration
	Throughput     float64 // records/sec
	ByteThroughput float64 // bytes/sec
	ErrorRate      float64 // errors/total

	// Stage breakdown
	StageMetrics map[string]*StageMetrics

	// Connector metrics
	SourceMetrics *ConnectorMetrics
	DestMetrics   *ConnectorMetrics

	// Channel metrics
	ChannelMetrics *ChannelMetrics

	// System metrics
	RuntimeMetrics *RuntimeMetrics

	// Bottleneck analysis
	BottleneckAnalysis *AnalysisResult

	// Recommendations
	Recommendations []string
}

ProfileResult contains complete pipeline profiling results

type ProfileType

type ProfileType string

ProfileType represents the type of profiling to perform

const (
	CPUProfile       ProfileType = "cpu"
	MemoryProfile    ProfileType = "memory"
	BlockProfile     ProfileType = "block"
	MutexProfile     ProfileType = "mutex"
	GoroutineProfile ProfileType = "goroutine"
	TraceProfile     ProfileType = "trace"
	AllProfiles      ProfileType = "all"
)

type Profiler

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

Profiler provides comprehensive profiling capabilities

func NewProfiler

func NewProfiler(config *ProfileConfig, logger *zap.Logger) *Profiler

NewProfiler creates a new profiler instance

func (*Profiler) GetRuntimeMetrics

func (p *Profiler) GetRuntimeMetrics() *RuntimeMetrics

GetRuntimeMetrics returns current runtime metrics

func (*Profiler) Start

func (p *Profiler) Start(ctx context.Context) error

Start begins profiling

func (*Profiler) Stop

func (p *Profiler) Stop() error

Stop stops profiling and saves results

type RuntimeMetrics

type RuntimeMetrics struct {
	// Memory metrics
	AllocBytes      uint64
	TotalAllocBytes uint64
	SysBytes        uint64
	NumGC           uint32
	GCPauseTotal    time.Duration
	GCPauseLast     time.Duration

	// Goroutine metrics
	NumGoroutines int

	// CPU metrics
	NumCPU     int
	GOMAXPROCS int

	// Samples over time
	Samples []MetricsSample
}

RuntimeMetrics contains runtime performance metrics

func ProfilePipeline

func ProfilePipeline(ctx context.Context, pipelineFunc func() error, config *ProfileConfig) (*RuntimeMetrics, error)

ProfilePipeline profiles a complete pipeline execution

type StageMetrics

type StageMetrics struct {
	Name           string
	RecordsIn      int64
	RecordsOut     int64
	ProcessingTime time.Duration
	ErrorCount     int64
	AvgLatency     time.Duration
	MaxLatency     time.Duration
	MinLatency     time.Duration
	// contains filtered or unexported fields
}

StageMetrics tracks metrics for a pipeline stage

Jump to

Keyboard shortcuts

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