coremetrics

package
v0.0.14-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package coremetrics collects bounded operational measurements for administrators.

Index

Constants

View Source
const SampleInterval = 30 * time.Second

Variables

View Source
var ErrInvalidRange = errors.New("invalid Core metrics range")

ErrInvalidRange reports a Core metrics range that is not one of the supported windows, or a history interval that is unbounded or not aligned to its resolution.

Functions

This section is empty.

Types

type Database

type Database struct {
	PingMS    Latency          `json:"ping_ms" binding:"required"`
	Pool      Pool             `json:"pool" binding:"required"`
	SizeBytes *int64           `json:"size_bytes" extensions:"x-nullable" binding:"required"`
	Series    []DatabaseBucket `json:"series" binding:"required"`
}

type DatabaseBucket

type DatabaseBucket struct {
	Start     time.Time `json:"start" binding:"required"`
	PingP95MS *float64  `json:"ping_p95_ms" extensions:"x-nullable" binding:"required"`
	PoolInUse *int64    `json:"pool_in_use" extensions:"x-nullable" binding:"required"`
}

type Execution

type Execution struct {
	SlotsInUse          int64             `json:"slots_in_use" binding:"required"`
	SlotsTotal          int64             `json:"slots_total" binding:"required"`
	QueuedTurns         *int64            `json:"queued_turns" extensions:"x-nullable" binding:"required"`
	WaitingForDaemon    *int64            `json:"waiting_for_daemon" extensions:"x-nullable" binding:"required"`
	InProgressTurns     *int64            `json:"in_progress_turns" extensions:"x-nullable" binding:"required"`
	OldestQueuedSeconds *float64          `json:"oldest_queued_seconds" extensions:"x-nullable" binding:"required"`
	ConnectedDaemons    int64             `json:"connected_daemons" binding:"required"`
	Interrupted         *int64            `json:"interrupted" extensions:"x-nullable" binding:"required"`
	Unavailable         *int64            `json:"unavailable" extensions:"x-nullable" binding:"required"`
	QueueWaitMS         Latency           `json:"queue_wait_ms" binding:"required"`
	Series              []ExecutionBucket `json:"series" binding:"required"`
}

type ExecutionBucket

type ExecutionBucket struct {
	Start          time.Time `json:"start" binding:"required"`
	Queued         *int64    `json:"queued" extensions:"x-nullable" binding:"required"`
	InProgress     *int64    `json:"in_progress" extensions:"x-nullable" binding:"required"`
	QueueWaitP95MS *float64  `json:"queue_wait_p95_ms" extensions:"x-nullable" binding:"required"`
}

type ExecutionSnapshot added in v0.0.10

type ExecutionSnapshot struct {
	QueuedTurns, WaitingForDaemon, InProgressTurns int64
	OldestQueuedSeconds                            *float64
}

ExecutionSnapshot counts the deployment's persisted root Turns.

type History

type History struct {
	Interrupted int64
	QueueWaitMS Latency
	Buckets     map[time.Time]*float64
}

History is the root Turn history of a range. Buckets maps each bucket's UTC start to its queue wait p95 in milliseconds, nil without observations.

type Job

type Job struct {
	ID        string     `json:"id" binding:"required"`
	Status    JobStatus  `json:"status" binding:"required"`
	LastRunAt *time.Time `json:"last_run_at" extensions:"x-nullable" binding:"required"`
	Processed *int64     `json:"processed" extensions:"x-nullable" binding:"required"`
	Failed    *int64     `json:"failed" extensions:"x-nullable" binding:"required"`
}

type JobStatus added in v0.0.10

type JobStatus string
const (
	JobOk      JobStatus = "ok"
	JobFailing JobStatus = "failing"
	JobStopped JobStatus = "stopped"
	JobUnknown JobStatus = "unknown"
)

type Latency

type Latency struct {
	P50 *float64 `json:"p50" extensions:"x-nullable" binding:"required"`
	P95 *float64 `json:"p95" extensions:"x-nullable" binding:"required"`
}

type Live

type Live struct {
	SlotsInUse, SlotsTotal, ConnectedDaemons int64
	ExecutionOwner                           *bool
	Pool                                     Pool
	Scheduler                                Job
}

type Periodic added in v0.0.10

type Periodic struct {
	ID    string
	Every time.Duration
	Run   func(context.Context) (processed *int64, failed int64, err error)
}

Periodic is a background job the metrics report. Run makes one bounded pass and returns what it processed, nil when the pass counted nothing, and what failed. The next pass starts Every after a pass ends; a panic fails that pass only. A job without Run is disabled and reports stopped.

type Pool

type Pool struct {
	InUse *int64 `json:"in_use" extensions:"x-nullable" binding:"required"`
	Idle  *int64 `json:"idle" extensions:"x-nullable" binding:"required"`
	Max   *int64 `json:"max" extensions:"x-nullable" binding:"required"`
}

type Process

type Process struct {
	MemoryBytes      *uint64         `json:"memory_bytes" extensions:"x-nullable" binding:"required"`
	Goroutines       *int64          `json:"goroutines" extensions:"x-nullable" binding:"required"`
	CPUCores         *float64        `json:"cpu_cores" extensions:"x-nullable" binding:"required"`
	CPULimitCores    *float64        `json:"cpu_limit_cores" extensions:"x-nullable" binding:"required"`
	RSSBytes         *uint64         `json:"rss_bytes" extensions:"x-nullable" binding:"required"`
	MemoryLimitBytes *uint64         `json:"memory_limit_bytes" extensions:"x-nullable" binding:"required"`
	Series           []ProcessBucket `json:"series" binding:"required"`
}

type ProcessBucket

type ProcessBucket struct {
	Start    time.Time `json:"start" binding:"required"`
	CPUCores *float64  `json:"cpu_cores" extensions:"x-nullable" binding:"required"`
	RSSBytes *uint64   `json:"rss_bytes" extensions:"x-nullable" binding:"required"`
}

type Range

type Range struct {
	Start             time.Time `json:"start" binding:"required"`
	End               time.Time `json:"end" binding:"required"`
	ResolutionSeconds int64     `json:"resolution_seconds" binding:"required"`
}

func Window

func Window(now time.Time, name string) (Range, error)

type Sample

type Sample struct {
	At                                   time.Time
	Queued, WaitingForDaemon, InProgress *int64
	OldestQueuedSeconds                  *float64
	PingMS                               *float64
	PoolInUse, DatabaseSize              *int64
	Healthy                              bool
	Process                              Process
}

Sample contains only measurements, never resource identities or error text.

type Service

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

func New

func New(started time.Time, revision string, source Source, jobs ...Periodic) (*Service, error)

New reports the scheduler, which the Source reads live, and then jobs in their order. Run runs the jobs. An enabled job needs a positive Every.

func (*Service) Read

func (s *Service) Read(ctx context.Context, name string) (View, error)

func (*Service) RecordUnavailable

func (s *Service) RecordUnavailable()

RecordUnavailable is called only when Core emits this exact rejection code. Fixed slots bound memory independently of request volume.

func (*Service) Run

func (s *Service) Run(ctx context.Context)

Run samples Core and runs every enabled job until ctx ends, then waits for them to stop.

type ServiceState

type ServiceState struct {
	Status         ServiceStatus `json:"status" binding:"required"`
	Revision       *string       `json:"revision" extensions:"x-nullable" binding:"required"`
	StartedAt      *time.Time    `json:"started_at" extensions:"x-nullable" binding:"required"`
	ExecutionOwner *bool         `json:"execution_owner" extensions:"x-nullable" binding:"required"`
}

type ServiceStatus added in v0.0.10

type ServiceStatus string
const (
	ServiceRunning  ServiceStatus = "running"
	ServiceDegraded ServiceStatus = "degraded"
)

type Source

type Source interface {
	Sample(context.Context) Sample
	History(context.Context, time.Time, time.Time, time.Duration) (History, error)
	Live() Live
}

type View

type View struct {
	Object    string       `json:"object" enums:"core.metrics" binding:"required"`
	Range     Range        `json:"range" binding:"required"`
	Service   ServiceState `json:"service" binding:"required"`
	Execution Execution    `json:"execution" binding:"required"`
	Database  Database     `json:"database" binding:"required"`
	Jobs      []Job        `json:"jobs" binding:"required"`
	Process   Process      `json:"process" binding:"required"`
}

Jump to

Keyboard shortcuts

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