Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithClient ¶
ContextWithClient returns a new context with the telemetry client
func IsNoopClient ¶
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
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
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