Help us shape the future of Go! Take the 2026 Go Developer Survey

metrics

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TierRaw = "raw"
	Tier1m  = "1m"
	Tier5m  = "5m"
	Tier1h  = "1h"
	Tier1d  = "1d"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppLookup

type AppLookup func(slug string) (int64, error)

AppLookup resolves an app slug to its database ID. Return (0, err) when the app is not found.

type Collector

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

Collector gathers system and container metrics.

func NewCollector

func NewCollector(dc docker.Client, appLookup AppLookup, out chan<- MetricPoint) *Collector

NewCollector creates a new Collector. appLookup may be nil; if so, AppID will always be nil.

func (*Collector) CollectContainers

func (c *Collector) CollectContainers(ctx context.Context) ([]MetricPoint, error)

CollectContainers collects metrics for all simpledeploy containers.

func (*Collector) CollectSystem

func (c *Collector) CollectSystem() (MetricPoint, error)

CollectSystem collects host-level CPU, memory metrics.

func (*Collector) Run

func (c *Collector) Run(ctx context.Context, interval time.Duration)

Run collects metrics on every interval tick until ctx is cancelled.

func (*Collector) SetStatusSyncer

func (c *Collector) SetStatusSyncer(ss StatusSyncer)

type MetricAggregator

type MetricAggregator interface {
	AggregateMetrics(sourceTier, destTier string, olderThan time.Time) error
	PruneMetrics(tier string, before time.Time) (int64, error)
}

MetricAggregator is implemented by store.Store.

type MetricInserter

type MetricInserter interface {
	InsertMetrics(points []MetricPoint) error
}

MetricInserter is implemented by store.Store.

type MetricPoint

type MetricPoint struct {
	AppID       *int64
	ContainerID string
	CPUPct      float64
	MemBytes    int64
	MemLimit    int64
	NetRx       float64
	NetTx       float64
	DiskRead    float64
	DiskWrite   float64
	Ts          int64
	Tier        string
}

type ReqMetricsAggregator

type ReqMetricsAggregator interface {
	AggregateRequestMetrics(sourceTier, destTier string, olderThan time.Time) error
	PruneRequestMetrics(tier string, before time.Time) (int64, error)
}

ReqMetricsAggregator is implemented by store.Store.

type ReqMetricsRollupManager

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

ReqMetricsRollupManager handles rollup and pruning for request metrics.

func NewReqMetricsRollupManager

func NewReqMetricsRollupManager(st ReqMetricsAggregator, tiers []TierConfig) *ReqMetricsRollupManager

func (*ReqMetricsRollupManager) Run

Run calls RunOnce every 60 seconds until ctx is cancelled.

func (*ReqMetricsRollupManager) RunOnce

func (rm *ReqMetricsRollupManager) RunOnce() error

RunOnce performs one round of aggregation and pruning for request metrics.

type RequestMetricPoint

type RequestMetricPoint struct {
	AppID      int64
	Ts         int64
	Tier       string
	Count      int64
	ErrorCount int64
	AvgLatency float64
	MaxLatency float64
}

type RequestMetricsInserter

type RequestMetricsInserter interface {
	InsertRequestMetrics(points []RequestMetricPoint) error
}

RequestMetricsInserter is implemented by store.Store.

type RequestMetricsWriter

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

func NewRequestMetricsWriter

func NewRequestMetricsWriter(st RequestMetricsInserter, in <-chan proxy.RequestStatEvent, appLookup func(string) (int64, error), bufSize int) *RequestMetricsWriter

func (*RequestMetricsWriter) Run

func (w *RequestMetricsWriter) Run(ctx context.Context, flushInterval time.Duration)

type RollupManager

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

func NewRollupManager

func NewRollupManager(st MetricAggregator, tiers []TierConfig) *RollupManager

func (*RollupManager) Run

func (rm *RollupManager) Run(ctx context.Context)

Run calls RunOnce every 60 seconds until ctx is cancelled.

func (*RollupManager) RunOnce

func (rm *RollupManager) RunOnce() error

RunOnce performs one round of aggregation and pruning.

type StatusApp

type StatusApp struct {
	Slug   string
	Status string
}

type StatusSyncer

type StatusSyncer interface {
	ListApps() ([]StatusApp, error)
	UpdateAppStatus(slug, status string) error
}

type TierConfig

type TierConfig struct {
	Name      string
	Retention time.Duration
}

type Writer

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

func NewWriter

func NewWriter(st MetricInserter, in <-chan MetricPoint, bufSize int) *Writer

func (*Writer) Run

func (w *Writer) Run(ctx context.Context, flushInterval time.Duration)

Jump to

Keyboard shortcuts

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