telemetry

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LifecycleStartSuccess = "start_success"
	LifecycleStop         = "stop"
	LifecycleStartError   = "start_error"
)

Lifecycle event type constants.

View Source
const (
	ErrCodePortConflict    = "port_conflict"
	ErrCodeImagePullFailed = "image_pull_failed"
	ErrCodeLicenseInvalid  = "license_invalid"
	ErrCodeStartFailed     = "start_failed"
)

Error codes for start_error lifecycle events.

Variables

This section is empty.

Functions

func LoadOrCreateMachineID

func LoadOrCreateMachineID() string

LoadOrCreateMachineID attempts to derive a stable, anonymized machine ID by trying in order: Docker daemon ID, /etc/machine-id, then a persisted random UUID. Prefixes (dkr_, sys_, gen_) indicate origin, matching the Python implementation in localstack-core so IDs can be correlated across tools.

func ToMap added in v0.5.2

func ToMap(v any) map[string]any

ToMap converts a telemetry event struct to a map[string]any for use with Emit.

Types

type Client

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

func New

func New(endpoint string, disabled bool) *Client

func (*Client) Close

func (c *Client) Close()

Close stops accepting new events, drains the event buffer, and blocks until all pending HTTP requests have completed. Call it before process exit to avoid dropping telemetry events.

func (*Client) Emit

func (c *Client) Emit(ctx context.Context, name string, payload map[string]any)

func (*Client) EmitCommand added in v0.5.2

func (c *Client) EmitCommand(ctx context.Context, command string, flags []string, durationMS int64, exitCode int, errorMsg string)

EmitCommand emits an lstk_command telemetry event. The Environment block is populated automatically from the client state.

func (*Client) EmitEmulatorLifecycleEvent added in v0.5.2

func (c *Client) EmitEmulatorLifecycleEvent(ctx context.Context, event LifecycleEvent)

EmitEmulatorLifecycleEvent emits an lstk_lifecycle telemetry event. The Environment field is populated automatically from the client state; any value set by the caller is overwritten.

func (*Client) GetEnvironment added in v0.5.2

func (c *Client) GetEnvironment() Environment

GetEnvironment returns the common environment payload for telemetry events, using the auth token set via SetAuthToken.

func (*Client) SetAuthToken added in v0.5.2

func (c *Client) SetAuthToken(token string)

SetAuthToken stores the resolved auth token for inclusion in telemetry events. Call this once the token is known (e.g. after keyring resolution or interactive login).

type CommandEvent added in v0.5.2

type CommandEvent struct {
	Environment Environment       `json:"environment"`
	Parameters  CommandParameters `json:"parameters"`
	Result      CommandResult     `json:"result"`
}

CommandEvent is the payload for an lstk_command telemetry event.

type CommandParameters added in v0.5.2

type CommandParameters struct {
	Command string   `json:"command"`
	Flags   []string `json:"flags"`
}

CommandParameters holds the command name and set flags.

type CommandResult added in v0.5.2

type CommandResult struct {
	DurationMS int64  `json:"duration_ms"`
	ExitCode   int    `json:"exit_code"`
	ErrorMsg   string `json:"error_msg,omitempty"`
}

CommandResult holds the outcome of a command invocation.

type Environment added in v0.5.2

type Environment struct {
	LstkVersion string `json:"lstk_version"`
	AuthTokenID string `json:"auth_token_id,omitempty"`
	MachineID   string `json:"machine_id,omitempty"`
	OS          string `json:"os"`
	Arch        string `json:"arch"`
}

Environment is the common environment block included in all telemetry events.

type LifecycleEvent added in v0.5.2

type LifecycleEvent struct {
	EventType      string          `json:"event_type"`
	Environment    Environment     `json:"environment"`
	Emulator       string          `json:"emulator"`
	Image          string          `json:"image,omitempty"`
	ContainerID    string          `json:"container_id,omitempty"`
	DurationMS     int64           `json:"duration_ms,omitempty"`
	Pulled         bool            `json:"pulled,omitempty"`
	LocalStackInfo *LocalStackInfo `json:"localstack_info,omitempty"`
	ErrorCode      string          `json:"error_code,omitempty"`
	ErrorMsg       string          `json:"error_msg,omitempty"`
}

LifecycleEvent is the payload for an lstk_lifecycle telemetry event.

type LocalStackInfo added in v0.5.2

type LocalStackInfo struct {
	Version            string `json:"version"`
	Edition            string `json:"edition"`
	IsLicenseActivated bool   `json:"is_license_activated"`
	SessionID          string `json:"session_id"`
	MachineID          string `json:"machine_id"`
	System             string `json:"system"`
	IsDocker           bool   `json:"is_docker"`
	ServerTimeUTC      string `json:"server_time_utc"`
	Uptime             int    `json:"uptime"`
}

LocalStackInfo mirrors the /_localstack/info response.

Jump to

Keyboard shortcuts

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