telemetry

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 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). 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 {
	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) (string, error)

func (Noop) Event

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

func (Noop) JobCompleted

func (Noop) JobCompleted(ledger.Record)

func (Noop) JobResolved

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

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) (string, error)

func (*PG) Event

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

func (*PG) JobCompleted

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

func (*PG) JobResolved

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

type Recorder

type Recorder interface {
	AgentUpdateTarget(context.Context, string) (string, 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)
	// JobCompleted merges the GitHub webhook's view of a finished job — repo,
	// workflow, run id, conclusion, queue/start/complete times — into the same
	// job_runs row (either side may land first).
	JobCompleted(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.

Jump to

Keyboard shortcuts

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