telemetry

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package telemetry persists the dispatch story the control plane otherwise drops: finished jobs (job_runs), agent liveness (agent_status), and a live transition feed (dispatch_events). Its daily sweep also enforces retention on the enrollment tables that share the pool. Everything here is best-effort — a telemetry failure must never fail dispatch — and hosted-only: the OSS single-host controller gets the no-op Recorder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Beat

type Beat struct {
	UpdateProtocol int
	Version        string
	UpdateState    string
	UpdateError    string
	Key            string
	Name           string
	Orgs           []string
	Labels         []string
	Capacity       int
	Busy           int
	// QueueDepth is how many jobs the agent reports as pending. On a blocked
	// host it is the difference between "idle" and "stalled with work waiting".
	QueueDepth int
	DiskFree   uint64
	DiskTotal  uint64
	Blocked    bool
}

Beat is one agent heartbeat: its liveness identity plus the capacity and image-store state carried on the poll. Blocked means the agent is refusing work because its store is under the host's free-space floor.

type Noop

type Noop struct{}

Noop is the OSS default: telemetry disabled.

func (Noop) AgentSeen

func (Noop) AgentSeen(Beat)

func (Noop) AgentUpdateTarget added in v0.2.5

func (Noop) AgentUpdateTarget(context.Context, string) (UpdateTarget, error)

func (Noop) Event

func (Noop) Event(string, string, string, map[string]any)

func (Noop) JobResolved

func (Noop) JobResolved(dispatch.Record, string)

func (Noop) JobUpdated added in v0.2.8

func (Noop) JobUpdated(ledger.Record)

type PG

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

PG is the Neon-backed Recorder, sharing the control plane's pool. All writes are handed to a single drain goroutine so a slow or stalled DB never adds latency to the dispatch handlers that emit telemetry.

func NewWithPool

func NewWithPool(ctx context.Context, pool *pgxpool.Pool) (*PG, error)

NewWithPool applies the telemetry schema and starts the drain worker and daily retention sweep, both stopping when ctx is done.

func (*PG) AgentSeen

func (p *PG) AgentSeen(b Beat)

func (*PG) AgentUpdateTarget added in v0.2.5

func (p *PG) AgentUpdateTarget(ctx context.Context, key string) (UpdateTarget, error)

func (*PG) Event

func (p *PG) Event(org, dispatchID, event string, payload map[string]any)

func (*PG) JobResolved

func (p *PG) JobResolved(rec dispatch.Record, status string)

func (*PG) JobUpdated added in v0.2.8

func (p *PG) JobUpdated(r ledger.Record)

type Recorder

type Recorder interface {
	AgentUpdateTarget(context.Context, string) (UpdateTarget, error)
	// JobResolved records the terminal dispatch state (done|failed|lost|
	// offer-expired) with the scheduling timestamps carried on the record.
	JobResolved(rec dispatch.Record, status string)
	// JobUpdated merges GitHub job identity and lifecycle timestamps without erasing completion data.
	JobUpdated(r ledger.Record)
	// AgentSeen upserts agent liveness, capacity and host state under the
	// caller's liveness key. Called on every poll; implementations throttle writes.
	AgentSeen(b Beat)
	// Event appends to the live transition feed and notifies listeners.
	Event(org, dispatchID, event string, payload map[string]any)
}

Recorder receives lifecycle signals from the server and webhook.

type UpdateTarget added in v0.2.7

type UpdateTarget struct {
	Version string
	Request string
}

Jump to

Keyboard shortcuts

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