telemetry

package
v0.1.0-preview.5.rc Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithClient

func ContextWithClient(ctx context.Context, client Client) context.Context

ContextWithClient returns a new context with the telemetry client

func IsNoopClient

func IsNoopClient(client Client) bool

IsNoopClient checks if the client is a NoopClient (disabled telemetry)

func WithMetricsContext

func WithMetricsContext(ctx context.Context, metrics *MetricsContext) context.Context

WithMetricsContext returns a new context with the metrics context

Types

type Client

type Client interface {
	// AddMetric emits a single metric
	AddMetric(ctx context.Context, metric Metric) error
	// Close cleans up any resources
	Close() error
}

Client defines the interface for telemetry operations

func ClientFromContext

func ClientFromContext(ctx context.Context) (Client, bool)

ClientFromContext retrieves the telemetry client from context

type Metric

type Metric struct {
	Value      float64           `json:"value"`
	Name       string            `json:"name"`
	Dimensions map[string]string `json:"dimensions"`
}

Metric represents a single metric with its value and dimensions

type MetricsContext

type MetricsContext struct {
	StartTime  time.Time         `json:"start_time"`
	Metrics    []Metric          `json:"metrics"`
	Properties map[string]string `json:"properties"`
}

MetricsContext holds all metrics collected during command execution

func MetricsFromContext

func MetricsFromContext(ctx context.Context) (*MetricsContext, error)

MetricsFromContext retrieves the metrics context

func NewMetricsContext

func NewMetricsContext() *MetricsContext

NewMetricsContext creates a new metrics context

func (*MetricsContext) AddMetric

func (m *MetricsContext) AddMetric(name string, value float64)

AddMetric adds a new metric to the context without dimensions

func (*MetricsContext) AddMetricWithDimensions

func (m *MetricsContext) AddMetricWithDimensions(name string, value float64, dimensions map[string]string)

AddMetricWithDimensions adds a new metric to the context with dimensions

type NoopClient

type NoopClient struct{}

NoopClient implements the Client interface with no-op methods

func NewNoopClient

func NewNoopClient() *NoopClient

NewNoopClient creates a new no-op client

func (*NoopClient) AddMetric

func (c *NoopClient) AddMetric(_ context.Context, _ Metric) error

AddMetric implements the Client interface

func (*NoopClient) Close

func (c *NoopClient) Close() error

Close implements the Client interface

type PostHogClient

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

PostHogClient implements the Client interface using PostHog

func NewPostHogClient

func NewPostHogClient(environment *common.AppEnvironment, namespace string) (*PostHogClient, error)

NewPostHogClient creates a new PostHog client

func (*PostHogClient) AddMetric

func (c *PostHogClient) AddMetric(_ context.Context, metric Metric) error

AddMetric implements the Client interface

func (*PostHogClient) Close

func (c *PostHogClient) Close() error

Close implements the Client interface

Jump to

Keyboard shortcuts

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