telemetry

package
v0.22.1-rc.6 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateCategory

func ValidateCategory(category string) bool

ValidateCategory checks if the feedback category is valid.

func ValidateMessage

func ValidateMessage(message string) error

ValidateMessage checks if the feedback message meets length requirements.

Types

type FeedbackContext

type FeedbackContext struct {
	Version              string `json:"version"`
	Edition              string `json:"edition"`
	OS                   string `json:"os"`
	Arch                 string `json:"arch"`
	ServerCount          int    `json:"server_count"`
	ConnectedServerCount int    `json:"connected_server_count"`
	RoutingMode          string `json:"routing_mode"`
}

FeedbackContext provides automatic system context alongside feedback.

type FeedbackRequest

type FeedbackRequest struct {
	Category string          `json:"category"` // bug, feature, other
	Message  string          `json:"message"`
	Email    string          `json:"email,omitempty"`
	Context  FeedbackContext `json:"context"`
}

FeedbackRequest is the user-submitted feedback payload.

type FeedbackResponse

type FeedbackResponse struct {
	Success  bool   `json:"success"`
	IssueURL string `json:"issue_url,omitempty"`
	Error    string `json:"error,omitempty"`
}

FeedbackResponse is the response from the telemetry backend.

type HeartbeatPayload

type HeartbeatPayload struct {
	AnonymousID          string `json:"anonymous_id"`
	Version              string `json:"version"`
	Edition              string `json:"edition"`
	OS                   string `json:"os"`
	Arch                 string `json:"arch"`
	GoVersion            string `json:"go_version"`
	ServerCount          int    `json:"server_count"`
	ConnectedServerCount int    `json:"connected_server_count"`
	ToolCount            int    `json:"tool_count"`
	UptimeHours          int    `json:"uptime_hours"`
	RoutingMode          string `json:"routing_mode"`
	QuarantineEnabled    bool   `json:"quarantine_enabled"`
	Timestamp            string `json:"timestamp"`
}

HeartbeatPayload is the anonymous telemetry payload sent periodically.

type RateLimiter

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

RateLimiter enforces a maximum number of requests per hour.

func NewRateLimiter

func NewRateLimiter(maxPerHour int) *RateLimiter

NewRateLimiter creates a rate limiter with the given max requests per hour.

func (*RateLimiter) Allow

func (rl *RateLimiter) Allow() bool

Allow returns true if the request is within the rate limit.

type RuntimeStats

type RuntimeStats interface {
	GetServerCount() int
	GetConnectedServerCount() int
	GetToolCount() int
	GetRoutingMode() string
	IsQuarantineEnabled() bool
}

RuntimeStats is an interface to decouple from the runtime package.

type Service

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

Service manages anonymous telemetry heartbeats and feedback submission.

func New

func New(cfg *config.Config, cfgPath, version, edition string, logger *zap.Logger) *Service

New creates a new telemetry service.

func (*Service) SetRuntimeStats

func (s *Service) SetRuntimeStats(stats RuntimeStats)

SetRuntimeStats sets the runtime stats provider (called after runtime is fully initialized).

func (*Service) Start

func (s *Service) Start(ctx context.Context)

Start begins the telemetry heartbeat loop. This is a blocking call; run in a goroutine.

func (*Service) SubmitFeedback

func (s *Service) SubmitFeedback(ctx context.Context, req *FeedbackRequest) (*FeedbackResponse, error)

SubmitFeedback sends feedback to the telemetry backend.

Jump to

Keyboard shortcuts

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