telemetry

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Disabled    bool   // true if MAINTENANT_DISABLE_TELEMETRY is truthy
	Endpoint    string // default: defaultEndpoint
	DataDir     string // default: defaultDataDir
	AppVersion  string // injected via ldflags at build time
	Environment string // default: defaultEnvironment
}

Config carries the wire-relevant constants for the telemetry subsystem. All fields have safe defaults populated by New when unset.

type Deps

type Deps struct {
	Containers       counter
	Endpoints        counter
	Heartbeats       counter
	Certificates     counter
	Webhooks         counter
	StatusComponents counter
	Edition          editionSource
}

Deps groups the count sources and edition source needed by the metrics provider. Each store satisfies the `counter` interface structurally.

type EditionFunc

type EditionFunc func() extension.Edition

EditionFunc adapts a func into an editionSource so callers can pass `telemetry.EditionFunc(extension.CurrentEdition)` at wiring time without declaring a struct.

func (EditionFunc) Current

func (f EditionFunc) Current() extension.Edition

Current returns the edition resolved at call time. No caching.

type Service

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

Service owns the SHM SDK client and its single reporting goroutine. Disabled instances (via opt-out or unwritable datadir) hold a nil client and treat Start as a no-op.

func New

func New(cfg Config, deps Deps, logger *slog.Logger) *Service

New constructs the telemetry service. It evaluates the opt-out and datadir-writability checks up-front and emits exactly one startup log line describing the resolved state (FR-017).

New never returns an error: failures during initialization disable telemetry for the lifetime of the process and are reported via the log line. This matches the spec's "best-effort, never destabilize the host" posture (FR-009 / FR-010 / FR-016).

func (*Service) IsActive

func (s *Service) IsActive() bool

IsActive reports whether the SDK client is initialised. Used by tests to assert opt-out and datadir-unwritable branches did not spawn the goroutine.

func (*Service) Start

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

Start spawns the SDK reporting goroutine if telemetry is enabled. The goroutine self-exits when ctx is cancelled. A panic inside the SDK is contained and logged (FR-012); it never propagates to the host.

Start is a no-op when telemetry is disabled. Calling Start more than once is allowed but only the first invocation spawns a goroutine.

Jump to

Keyboard shortcuts

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