telemetry

package
v1.10.21 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package telemetry sends one minimal, anonymous event per startup and per day so the project can count installations. It is fire-and-forget: a failure is logged at debug and never affects the platform.

Index

Constants

View Source
const (
	EventStartup = "startup"
	EventDaily   = "daily"
)

Events a payload can carry.

View Source
const (
	PlatformStandalone = "standalone"
	PlatformSwarm      = "swarm"
)

Platforms the control plane reports.

View Source
const Endpoint = "https://miabi.io/api/v1/telemetry/installations"
View Source
const SchemaVersion = 1

SchemaVersion is the payload format the receiver validates against.

Variables

This section is empty.

Functions

func InstallationID

func InstallationID(installID string) string

InstallationID derives the anonymous id sent for an Install ID.

func IsRelease

func IsRelease(v string) bool

IsRelease reports whether v is a semver release stamp rather than "dev" or a commit sha.

Types

type Options

type Options struct {
	URL       string
	Version   string
	InstallID string
	Enabled   bool
	Edition   func() string
	Platform  func() string
	Redis     redis.Cmdable
}

Options wires the service to the platform. The funcs are read at send time so a licence install or a swarm change is reflected without a restart.

type Payload

type Payload struct {
	Schema         int    `json:"schema"`
	InstallationID string `json:"installation_id"`
	Event          string `json:"event"`
	Version        string `json:"version"`
	Edition        string `json:"edition"`
	Platform       string `json:"platform"`
	OS             string `json:"os"`
	Arch           string `json:"arch"`
}

Payload is everything a telemetry event contains.

type Service

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

Service builds and sends telemetry events.

func New

func New(opts Options) *Service

New builds the service.

func (*Service) Enabled

func (s *Service) Enabled() bool

Enabled reports whether events are sent at all. Non-release builds never send so development and CI don't count as installations.

func (*Service) Payload

func (s *Service) Payload(event string) Payload

Payload builds the event exactly as it would be sent.

func (*Service) Send

func (s *Service) Send(ctx context.Context, event string) error

Send posts one event when enabled. The response is never interpreted beyond its status.

func (*Service) SendStartup

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

SendStartup sends the startup event after a random 1–5 minute delay, at most once per version per hour across every control plane sharing Redis. Run it in a goroutine; it returns when ctx is done or the send finished.

Jump to

Keyboard shortcuts

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