telemetry

package
v0.2.8 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: 22 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 BootTrace added in v0.2.6

func BootTrace(ctx context.Context, req BootTraceRequest)

BootTrace emits a root "chinit.boot" span with one child span per executed step using the engine's recorded timestamps. No-op when trace telemetry is disabled.

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 ForceFlush added in v0.2.6

func ForceFlush(ctx context.Context) error

ForceFlush flushes pending metrics and spans without tearing down the active providers.

func Init

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

Init installs the process-wide metric and/or trace providers. Idempotent: a second call (tests, re-entry) is a no-op while the first provider lives. When neither an OTLP metrics endpoint nor a traces endpoint resolves, the package stays in its disabled zero state — Init returns nil and every emit no-ops.

func InitWithProviders added in v0.2.6

func InitWithProviders(cfg Config, reader metric.Reader, spanExp sdktrace.SpanExporter) error

InitWithProviders installs caller-supplied metric reader and/or span exporter (the specs' collection seam for both metrics and traces).

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 metric and trace providers and tears them down. Safe on the disabled zero state. The flush deadline bounds the collector-unreachable case so a dying job never hangs on telemetry.

func StartJobSpan added in v0.2.6

func StartJobSpan(ctx context.Context, job string) (context.Context, func(outcome string, runErr error))

StartJobSpan opens a root span for a chinit subcommand execution when trace export is enabled, returning a finish closure that sets the outcome status/attributes and ends the span. No-op when disabled.

func TracesEnabled added in v0.2.6

func TracesEnabled() bool

TracesEnabled reports whether Init wired a live TracerProvider.

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 BootTraceRequest added in v0.2.6

type BootTraceRequest struct {
	StartedAt  time.Time
	FinishedAt time.Time
	Refresh    bool
	Fatality   error
	Steps      []BootTraceStep
}

BootTraceRequest carries the boot pipeline run's timing and outcome so BootTrace can emit one correlated trace waterfall ("chinit.boot" root span + child spans per step).

type BootTraceStep added in v0.2.6

type BootTraceStep struct {
	Name        string
	Criticality string
	StartedAt   time.Time
	Duration    time.Duration
	Err         error
	Skipped     bool
}

BootTraceStep describes one step's timing and verdict for BootTrace.

type Config

type Config struct {
	// Endpoint is the base OTLP/HTTP target — the spec's
	// log_shipping.endpoint. Empty disables telemetry unless
	// MetricsEndpoint or TracesEndpoint is explicitly set.
	Endpoint string
	// MetricsEndpoint overrides Endpoint for OTLP metrics (e.g.
	// VictoriaMetrics "/opentelemetry/v1/metrics"). Prometheus Remote
	// Write URLs ("/api/v1/write") are scraped/forwarded by otelcol.
	MetricsEndpoint string
	// TracesEndpoint overrides Endpoint for OTLP traces (e.g.
	// VictoriaTraces "/insert/opentelemetry/v1/traces").
	TracesEndpoint string
	// Headers are comma-separated k=v pairs from log_shipping.headers
	// (bearer tokens for collector front doors that need them).
	Headers string
	// MetricsHeaders / TracesHeaders optionally override Headers per signal.
	MetricsHeaders string
	TracesHeaders  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.

type OTLPSpanSink added in v0.2.6

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

OTLPSpanSink implements port.SpanSink over the OpenTelemetry Go SDK's otlptracehttp exporter.

func NewOTLPSpanSink added in v0.2.6

func NewOTLPSpanSink(cfg OTLPSpanSinkConfig) *OTLPSpanSink

NewOTLPSpanSink constructs an OTLPSpanSink for cfg.

func (*OTLPSpanSink) BuildReadOnlySpans added in v0.2.6

func (s *OTLPSpanSink) BuildReadOnlySpans(batch port.SpanBatch) []sdktrace.ReadOnlySpan

BuildReadOnlySpans maps a domain SpanBatch into OpenTelemetry SDK ReadOnlySpan records preserving TraceID, SpanID, ParentSpanID, and microsecond timestamps.

func (*OTLPSpanSink) Export added in v0.2.6

func (s *OTLPSpanSink) Export(ctx context.Context, batch port.SpanBatch) (int, error)

Export converts batch into SDK ReadOnlySpans and pushes them via otlptracehttp, returning the count of exported spans.

type OTLPSpanSinkConfig added in v0.2.6

type OTLPSpanSinkConfig struct {
	EndpointURL string
	Headers     string
	// Exporter is an optional test seam; nil builds an otlptracehttp
	// exporter targeting EndpointURL.
	Exporter sdktrace.SpanExporter
}

OTLPSpanSinkConfig configures OTLPSpanSink's OTLP/HTTP destination.

Jump to

Keyboard shortcuts

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