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

telemetry

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package telemetry owns generation event context identity and lifecycle orchestration.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLifecycleStart indicates that a telemetry lifecycle could not start.
	ErrLifecycleStart = errors.New("start telemetry lifecycle")
	// ErrNilEvent indicates that a telemetry lifecycle returned no active event.
	ErrNilEvent = errors.New("telemetry lifecycle returned a nil event")
)

Functions

func EventFromContext

func EventFromContext(ctx context.Context) *shared.CliEvent

EventFromContext returns the active event, if any.

func Run

func Run(
	ctx context.Context,
	interactionType shared.InteractionType,
	callback func(context.Context, *shared.CliEvent) error,
) (resultErr error)

Run starts an event, invokes the callback with the same event in its context, and finalizes the event after callback execution starts.

func WithEvent

func WithEvent(ctx context.Context, event *shared.CliEvent) context.Context

WithEvent stores the active event without changing its pointer identity.

func WithLifecycle

func WithLifecycle(ctx context.Context, lifecycle Lifecycle) context.Context

WithLifecycle selects the lifecycle used by Run. A nil lifecycle selects the default no-delivery lifecycle.

Types

type Lifecycle

type Lifecycle interface {
	Start(context.Context, shared.InteractionType) (*shared.CliEvent, error)
	Finish(context.Context, *shared.CliEvent, error) error
}

Lifecycle constructs and finalizes generation events. Delivery-capable implementations remain responsible for honoring access telemetry opt-out state.

type NoDeliveryLifecycle

type NoDeliveryLifecycle struct{}

NoDeliveryLifecycle creates and finalizes real events without persistence or network delivery.

func (NoDeliveryLifecycle) Finish

func (NoDeliveryLifecycle) Finish(_ context.Context, event *shared.CliEvent, callbackErr error) error

Finish records completion once and performs no persistence or delivery. Event mutation is single-writer; shared.CliEvent is not concurrency-safe.

func (NoDeliveryLifecycle) Start

Start creates an event using local time and cryptographically random IDs.

Jump to

Keyboard shortcuts

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