telemetry

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 11 Imported by: ? 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 telemetry provides OpenTelemetry metric emission over OTLP/HTTP for chinit boot steps and maintenance subcommands.

Index

Constants

View Source
const (
	// OutcomeCompleted is a successful run.
	OutcomeCompleted = "completed"
	// OutcomeFailed is an erroring run (the CLI's terminal error).
	OutcomeFailed = "failed"
	// OutcomeSkipped is a deliberate no-op run (role gates, not-
	// this-node's-job guards).
	OutcomeSkipped = "skipped"
)

Outcome attrs for job/boot counters.

Variables

This section is empty.

Functions

func BackupOutcome

func BackupOutcome(ctx context.Context, req BackupOutcomeRequest)

BackupOutcome records the nightly backup pass's verdict (the OTEL dual-write beside the CloudWatch push the backup-missing alarm keys on).

func BootOutcome

func BootOutcome(ctx context.Context, req BootOutcomeRequest)

BootOutcome records the whole pipeline's verdict (Fatality != nil is OutcomeFailed; a dry-run plan or a refresh that converged counts as completed).

func BootStep

func BootStep(ctx context.Context, req BootStepRequest)

BootStep records one boot step's duration by outcome (the engine's StepOutcome rows, emitted once at boot end — the histogram's cumulative view is what a slow-step alert keys on).

func DiskPressure

func DiskPressure(ctx context.Context, req DiskPressureRequest)

DiskPressure records the disk-autoscale job's probe and grow outcome (the OTEL dual-write beside the CloudWatch push).

func Enabled

func Enabled() bool

Enabled reports whether Init wired a live provider (the CLI's WARNING seam: disabled telemetry is loud once, not once per emit).

func FleetPoll

func FleetPoll(ctx context.Context, req FleetPollRequest)

FleetPoll records one executor tick's claims and verdicts.

func FleetSweep

func FleetSweep(ctx context.Context, req FleetSweepRequest)

FleetSweep records the coordinator's tick: the inventory gauges and the two transition counters. The domain result's fields are the exact numbers the journal line prints.

func Init

func Init(ctx context.Context, cfg Config) error

Init installs the process-wide provider. Idempotent: a second call (tests, re-entry) is a no-op while the first provider lives. When cfg.Endpoint is empty the package stays in its disabled zero state — Init returns nil and every emit no-ops, the same degradation rule as the MetricPusher capability (a cloud without a metrics pipeline logs a WARNING at the callsite and the job still exits 0).

func InitWithReader

func InitWithReader(cfg Config, reader metric.Reader) error

InitWithReader installs the provider over a caller-supplied reader instead of the OTLP exporter (the specs' collection seam — a sdk/metric/manual.Reader collects the datapoints in-process; the production path never calls it). Same config, same instruments, same disabled-when-empty rule.

func JobRun

func JobRun(ctx context.Context, req JobRunRequest)

JobRun records one subcommand's outcome and wall-clock duration (the dispatch wrapper's single emit per process).

func KeeperUp

func KeeperUp(ctx context.Context, req KeeperUpRequest)

KeeperUp records the mntr probe verdict (the OTEL dual-write beside the CloudWatch PutMetric the keeper_down alarm already keys on).

func Shutdown

func Shutdown(ctx context.Context) error

Shutdown flushes the provider and tears it down. Safe on the disabled zero state. The flush deadline bounds the collector- unreachable case so a dying job never hangs on telemetry; a flush failure is returned (the CLI logs it as a WARNING — the job's own outcome stands, the same rule as pushKeeperUp).

Types

type BackupOutcomeRequest

type BackupOutcomeRequest struct {
	// Success is true when the create/upload/delete-local pass ran
	// clean.
	Success bool
	// Host is the emitting node's hostname.
	Host string
}

BackupOutcomeRequest is the BackupOutcome emit request.

type BootOutcomeRequest

type BootOutcomeRequest struct {
	// Failed is true when RunResult.Fatality != nil.
	Failed bool
	// Refresh is true for a boot -refresh run.
	Refresh bool
}

BootOutcomeRequest is the BootOutcome emit request.

type BootStepRequest

type BootStepRequest struct {
	// Step is the pipeline step name (StepOutcome.Name).
	Step string
	// DurationSeconds is the step's engine-measured duration.
	DurationSeconds float64
	// Failed/Skipped mirror StepOutcome.Err/Skipped.
	Failed  bool
	Skipped bool
}

BootStepRequest is the BootStep emit request.

type Config

type Config struct {
	// Endpoint is the OTLP/HTTP metrics target — the spec's
	// log_shipping.endpoint. Empty disables the whole package (every
	// emit no-ops).
	Endpoint string
	// Headers are comma-separated k=v pairs from log_shipping.headers
	// (bearer tokens for collector front doors that need them).
	Headers string
	// ServiceVersion is the chinit build (app.Version).
	ServiceVersion string
	// InstanceID is the emitting process's identity — the settled
	// hostname (subcommands) or the provider instance id (boot, before
	// identity settles).
	InstanceID string
	// Cluster is the ClickHouse cluster name (identity.ClusterName).
	Cluster string
	// Role is the node role ("writer"/"reader"/"keeper"/"backup"; the
	// boot's spec may be empty when identity is not settled yet).
	Role string
	// Cloud is the provider name ("aws"/"azure").
	Cloud string
	// Region is the provider region.
	Region string
}

Config is the init request (the two-parameter style: one struct, no growing positional lists).

type DiskPressureRequest

type DiskPressureRequest struct {
	// FreeGB is the effective free space (the gauge alarms key on).
	FreeGB float64
	// Grew is true when this run grew the volume.
	Grew bool
	// Host is the emitting node's hostname (the per-node dimension
	// the CloudWatch dimensions carry too).
	Host string
}

DiskPressureRequest is the DiskPressure emit request.

type FleetPollRequest

type FleetPollRequest struct {
	Claimed   int
	Completed int
	Failed    int
}

FleetPollRequest is the FleetPoll emit request (the domain FleetTaskExecutorResult's fields).

type FleetSweepRequest

type FleetSweepRequest struct {
	Rows          int
	Redispatched  int
	Failed        int
	LeftPending   int
	LiveExecuting int
}

FleetSweepRequest is the FleetSweep emit request (the domain FleetTaskSweepResult's fields).

type JobRunRequest

type JobRunRequest struct {
	// Job is the subcommand name ("schema-sync", "boot", ...).
	Job string
	// Outcome is OutcomeCompleted/OutcomeFailed/OutcomeSkipped.
	Outcome string
	// DurationSeconds is the subcommand's wall-clock time.
	DurationSeconds float64
}

JobRunRequest is the JobRun emit request.

type KeeperUpRequest

type KeeperUpRequest struct {
	// Up is 1.0 (probe ok) or 0.0 (probe failed).
	Up float64
}

KeeperUpRequest is the KeeperUp emit request.

Jump to

Keyboard shortcuts

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