metrics

package
v1.33.21 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMetrics

func FormatMetrics(m *BuildMetrics) string

FormatMetrics formats metrics for display

Types

type BuildMetrics

type BuildMetrics struct {
	// Build identification
	BuildID   string    `json:"build_id"`
	StartTime time.Time `json:"start_time"`
	EndTime   time.Time `json:"end_time"`
	Duration  float64   `json:"duration_seconds"`

	// File metrics
	TotalProtoFiles  int   `json:"total_proto_files"`
	ProcessedFiles   int   `json:"processed_files"`
	GeneratedFiles   int   `json:"generated_files"`
	SkippedFiles     int   `json:"skipped_files"`
	FailedFiles      int   `json:"failed_files"`
	TotalInputBytes  int64 `json:"total_input_bytes"`
	TotalOutputBytes int64 `json:"total_output_bytes"`

	// Performance metrics
	FilesPerSecond  float64 `json:"files_per_second"`
	BytesPerSecond  float64 `json:"bytes_per_second"`
	AverageFileTime float64 `json:"average_file_time_ms"`

	// Cache metrics
	CacheHits    int     `json:"cache_hits"`
	CacheMisses  int     `json:"cache_misses"`
	CacheHitRate float64 `json:"cache_hit_rate"`

	// Language breakdown
	LanguageMetrics map[string]*LanguageMetrics `json:"language_metrics"`

	// Error metrics
	ErrorCount   int      `json:"error_count"`
	WarningCount int      `json:"warning_count"`
	Errors       []string `json:"errors,omitempty"`

	// Memory metrics (estimated)
	PeakMemoryMB float64 `json:"peak_memory_mb"`

	// Build options
	Workers      int  `json:"workers"`
	Incremental  bool `json:"incremental"`
	CacheEnabled bool `json:"cache_enabled"`
}

BuildMetrics contains metrics collected during a build

type Collector

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

Collector collects build metrics

func NewCollector

func NewCollector() *Collector

NewCollector creates a new metrics collector

func (*Collector) Finalize

func (c *Collector) Finalize() *BuildMetrics

Finalize calculates final metrics

func (*Collector) GetMetrics

func (c *Collector) GetMetrics() *BuildMetrics

GetMetrics returns the current metrics

func (*Collector) RecordCacheMiss

func (c *Collector) RecordCacheMiss()

RecordCacheMiss records a cache miss

func (*Collector) RecordError

func (c *Collector) RecordError(msg string)

RecordError records an error

func (*Collector) RecordFileFailed

func (c *Collector) RecordFileFailed(file string, err error)

RecordFileFailed records a failed file

func (*Collector) RecordFileGenerated

func (c *Collector) RecordFileGenerated(language string, file string, bytes int64)

RecordFileGenerated records a generated file

func (*Collector) RecordFileProcessed

func (c *Collector) RecordFileProcessed(file string, inputBytes int64, duration time.Duration)

RecordFileProcessed records a processed file

func (*Collector) RecordFileSkipped

func (c *Collector) RecordFileSkipped(file string)

RecordFileSkipped records a skipped file (cache hit)

func (*Collector) RecordWarning

func (c *Collector) RecordWarning(msg string)

RecordWarning records a warning

func (*Collector) SetBuildOptions

func (c *Collector) SetBuildOptions(workers int, incremental, cacheEnabled bool)

SetBuildOptions sets build configuration options

func (*Collector) SetTotalFiles

func (c *Collector) SetTotalFiles(count int)

SetTotalFiles sets the total number of proto files

type LanguageMetrics

type LanguageMetrics struct {
	Language       string  `json:"language"`
	FilesGenerated int     `json:"files_generated"`
	BytesGenerated int64   `json:"bytes_generated"`
	Duration       float64 `json:"duration_seconds"`
	Errors         int     `json:"errors"`
}

LanguageMetrics contains metrics for a specific language

type Store

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

Store stores metrics to file

func NewStore

func NewStore(dir string) (*Store, error)

NewStore creates a new metrics store

func (*Store) List

func (s *Store) List(limit int) ([]*BuildMetrics, error)

List returns all stored metrics

func (*Store) LoadByID

func (s *Store) LoadByID(buildID string) (*BuildMetrics, error)

LoadByID loads metrics by build ID

func (*Store) LoadLatest

func (s *Store) LoadLatest() (*BuildMetrics, error)

LoadLatest loads the most recent metrics

func (*Store) Save

func (s *Store) Save(metrics *BuildMetrics) error

Save saves metrics to file

Jump to

Keyboard shortcuts

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