Help us shape the future of Go! Take the 2026 Go Developer Survey

telemetry

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package telemetry provides opt-out anonymous usage telemetry for unum.

Telemetry is sent via OpenTelemetry (OTLP HTTP) and is disabled when:

  • OTEL_EXPORTER_OTLP_ENDPOINT is empty (dev builds)
  • DO_NOT_TRACK=1 or UNUM_NO_TELEMETRY=1 is set
  • "telemetry": false in config.json
  • --no-telemetry CLI flag is used

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics added in v1.4.0

type Metrics struct {
	// Invocations counts tool executions. Attributes: tool, mode, os, arch, version.
	Invocations ometric.Int64Counter
	// InputBytes records input file sizes in bytes. Attributes: tool.
	InputBytes ometric.Int64Histogram
	// Duration records processing time in seconds. Attributes: tool, mode.
	Duration ometric.Float64Histogram
	// Errors counts failed executions. Attributes: tool, error_type.
	Errors ometric.Int64Counter
	// JSONNodes records JSON node count per parse.
	JSONNodes ometric.Int64Histogram
	// DiffChanges counts added/removed/modified lines. Attributes: kind.
	DiffChanges ometric.Int64Counter
	// WebUploads counts file uploads to the hosted web UI. Attributes: tool.
	WebUploads ometric.Int64Counter
}

Metrics holds pre-created OTel instruments for recording usage data. All instruments are initialised from a real or noop meter — never nil.

type Telemetry

type Telemetry struct {
	Umami *UmamiClient
	M     Metrics
	// contains filtered or unexported fields
}

Telemetry is the unified facade for all telemetry systems. All methods are safe to call on a nil or disabled instance.

func Init

func Init(cfg config.Config, serviceName, version string) *Telemetry

Init creates a Telemetry instance. If telemetry is disabled (config, env, or missing endpoint), returns a fully functional but no-op instance.

func (*Telemetry) Close

func (t *Telemetry) Close(ctx context.Context) error

Close flushes pending telemetry data. Should be called before process exit.

func (*Telemetry) Disable

func (t *Telemetry) Disable()

Disable switches telemetry to no-op mode. Called when --no-telemetry is set.

func (*Telemetry) Meter

func (t *Telemetry) Meter() ometric.Meter

Meter returns the OTel meter. Returns a no-op meter if disabled.

func (*Telemetry) Tracer

func (t *Telemetry) Tracer() otrace.Tracer

Tracer returns the OTel tracer. Returns a no-op tracer if disabled.

func (*Telemetry) TrackEvent

func (t *Telemetry) TrackEvent(event, pageURL string, props map[string]string)

TrackEvent sends a named event to Umami (web mode only). No-op if Umami is not configured or telemetry is disabled.

type UmamiClient

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

UmamiClient sends page-level analytics events to a self-hosted Umami instance. Used only in web mode — CLI and TUI telemetry goes through OTel.

func NewUmami

func NewUmami(endpoint, websiteID, hostname string) *UmamiClient

NewUmami creates a client. If endpoint or websiteID is empty, the client is disabled (all methods are no-ops).

func (*UmamiClient) Track

func (u *UmamiClient) Track(event, pageURL string, props map[string]string)

Track sends a named event to Umami. Non-blocking (fires a goroutine). Safe to call on a disabled client.

Jump to

Keyboard shortcuts

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