telemetry

package
v0.66.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package telemetry provides telemetry functionality for the ToolHive operator.

Index

Constants

This section is empty.

Variables

View Source
var ErrInstanceIDUnavailable = stderrors.New("telemetry instance ID unavailable")

ErrInstanceIDUnavailable is returned by EnsureInstanceID when the ID could not be read or stored because of errors that may be transient (the API server is unreachable, overloaded or timing out). The caller should exit and let the pod restart rather than run without the ID: workload pod templates carry it, so a replica running without it would roll every workload when it becomes the leader, and roll them back when leadership moves again.

View Source
var InstanceIDBackoff = wait.Backoff{Steps: 5, Duration: time.Second, Factor: 2, Jitter: 0.1}

InstanceIDBackoff is how EnsureInstanceID retries at operator startup: five attempts over about 15 seconds.

Functions

This section is empty.

Types

type LeaderTelemetryRunnable

type LeaderTelemetryRunnable struct {
	TelemetryService *Service
}

LeaderTelemetryRunnable runs telemetry checks only when this instance is the leader

func (*LeaderTelemetryRunnable) NeedsLeaderElection

func (*LeaderTelemetryRunnable) NeedsLeaderElection() bool

NeedsLeaderElection indicates whether this runnable needs leader election

func (*LeaderTelemetryRunnable) Start

Start starts the telemetry runner

type Service

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

Service handles telemetry operations for the operator

func NewService

func NewService(k8sClient client.Client, namespace string) *Service

NewService creates a new Service instance

func (*Service) CheckForUpdates

func (s *Service) CheckForUpdates(ctx context.Context) error

CheckForUpdates checks for updates and sends telemetry data

func (*Service) EnsureInstanceID added in v0.66.0

func (s *Service) EnsureInstanceID(ctx context.Context, reader client.Reader, backoff wait.Backoff) (string, error)

EnsureInstanceID returns this operator installation's instance ID, creating and storing it in the telemetry ConfigMap if it does not exist yet, or if the ConfigMap holds no usable ID. It is meant to run once at startup, before the manager's cache starts, so it reads through the given uncached reader.

Errors that may be transient are retried with the given backoff, within an overall deadline; if they persist, the error wraps ErrInstanceIDUnavailable. Errors that a retry cannot fix (forbidden, unauthorized, invalid) are returned at once: every replica gets the same error, so they all run without the ID and agree. Concurrent replicas may race to write the ID; the loser reads the winner's ID. Returns an empty ID when update checks are disabled, without touching the ConfigMap.

func (*Service) StartTelemetryWorker

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

StartTelemetryWorker starts a background worker that periodically checks for updates This should only be called by the leader

Jump to

Keyboard shortcuts

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