Documentation
¶
Index ¶
- Constants
- func ApplyCredentials(accounts []core.AccountConfig) []core.AccountConfig
- func DisabledAccountsFromConfig() map[string]bool
- func DisabledAccountsFromDashboard(dashboardCfg config.DashboardConfig) map[string]bool
- func EnsureSocketPathAvailable(socketPath string) error
- func FilterAccountsByDashboard(accounts []core.AccountConfig, dashboardCfg config.DashboardConfig) []core.AccountConfig
- func FlushInBatches(ctx context.Context, pipeline *telemetry.Pipeline, maxTotal int) (telemetry.FlushResult, []string)
- func HealthAPICompatible(health HealthResponse) bool
- func HealthCurrent(health HealthResponse) bool
- func HealthProviderRegistryCompatible(health HealthResponse) bool
- func HealthVersion(health HealthResponse) string
- func InstallService(socketPath string) error
- func IsReleaseSemver(value string) bool
- func LastErrorLine(path string) string
- func LoadAccountsAndNorm() ([]core.AccountConfig, core.ModelNormalizationConfig, error)
- func ProviderRegistryHash() string
- func ReadModelRequestKey(req ReadModelRequest) string
- func ReadModelTemplatesFromRequest(req ReadModelRequest, disabledAccounts map[string]bool) map[string]core.UsageSnapshot
- func ResolveAccounts(cfg *config.Config) []core.AccountConfig
- func ResolveSocketPath() string
- func ResolveSocketPathWithError() (string, error)
- func ResolveTelemetrySourceOptions(source shared.TelemetrySource, requestedAccountID string) (shared.TelemetryCollectOptions, string, []string)
- func RunCommand(name string, args ...string) (string, error)
- func RunServer(cfg Config) error
- func ServiceStatus(ctx context.Context, socketPath string, details bool) error
- func SnapshotsHaveUsableData(snaps map[string]core.UsageSnapshot) bool
- func SocketOwnerSummary(socketPath string) string
- func StartBroadcaster(ctx context.Context, rt *ViewRuntime, refreshInterval time.Duration, ...)
- func StartupDiagnostics(manager ServiceManager, socketPath string) string
- func TailFile(path string, maxLines int) string
- func TailTextLines(text string, maxLines int) string
- func UninstallService(socketPath string) error
- func WaitForHealth(ctx context.Context, client *Client, timeout time.Duration) error
- type Client
- func (c *Client) HealthInfo(ctx context.Context) (HealthResponse, error)
- func (c *Client) IngestHook(ctx context.Context, source string, accountID string, payload []byte) (HookResponse, error)
- func (c *Client) ReadModel(ctx context.Context, request ReadModelRequest) (map[string]core.UsageSnapshot, error)
- type Config
- type DaemonState
- type DaemonStatus
- type HealthResponse
- type HookParseResult
- type HookResponse
- type PollScheduler
- func (ps *PollScheduler) EffectiveInterval(accountID string) time.Duration
- func (ps *PollScheduler) RecordPoll(accountID string, changed bool)
- func (ps *PollScheduler) ShouldPoll(accountID string, hasLocalDetector bool) bool
- func (ps *PollScheduler) SnapshotChanged(accountID string, snap core.UsageSnapshot) bool
- type ReadModelAccount
- type ReadModelRequest
- type ReadModelResponse
- type Service
- type ServiceManager
- func (m ServiceManager) Install() error
- func (m ServiceManager) InstallHint() string
- func (m ServiceManager) IsInstalled() bool
- func (m ServiceManager) IsSupported() bool
- func (m ServiceManager) Start() error
- func (m ServiceManager) StatusHint() string
- func (m ServiceManager) StderrLogPath() string
- func (m ServiceManager) StdoutLogPath() string
- func (m ServiceManager) Uninstall() error
- type SnapshotFrame
- type SnapshotHandler
- type StateHandler
- type ViewRuntime
- func (r *ViewRuntime) CurrentClient() *Client
- func (r *ViewRuntime) EnsureClient(ctx context.Context) *Client
- func (r *ViewRuntime) ReadWithFallback(ctx context.Context) SnapshotFrame
- func (r *ViewRuntime) ReadWithFallbackForWindow(ctx context.Context, timeWindow core.TimeWindow) SnapshotFrame
- func (r *ViewRuntime) ResetEnsureThrottle()
- func (r *ViewRuntime) SetClient(client *Client)
- func (r *ViewRuntime) SetTimeWindow(tw core.TimeWindow)
- func (r *ViewRuntime) State() DaemonState
- func (r *ViewRuntime) TimeWindow() core.TimeWindow
Constants ¶
const ( LaunchdDaemonLabel = "com.openusage.telemetryd" SystemdDaemonUnit = "openusage-telemetry.service" )
const APIVersion = "v1"
Variables ¶
This section is empty.
Functions ¶
func ApplyCredentials ¶
func ApplyCredentials(accounts []core.AccountConfig) []core.AccountConfig
func DisabledAccountsFromDashboard ¶
func DisabledAccountsFromDashboard(dashboardCfg config.DashboardConfig) map[string]bool
func FilterAccountsByDashboard ¶
func FilterAccountsByDashboard( accounts []core.AccountConfig, dashboardCfg config.DashboardConfig, ) []core.AccountConfig
func FlushInBatches ¶
func HealthAPICompatible ¶
func HealthAPICompatible(health HealthResponse) bool
func HealthCurrent ¶
func HealthCurrent(health HealthResponse) bool
func HealthProviderRegistryCompatible ¶ added in v0.6.0
func HealthProviderRegistryCompatible(health HealthResponse) bool
func HealthVersion ¶
func HealthVersion(health HealthResponse) string
func InstallService ¶
func IsReleaseSemver ¶
func LastErrorLine ¶ added in v0.6.0
func LoadAccountsAndNorm ¶
func LoadAccountsAndNorm() ([]core.AccountConfig, core.ModelNormalizationConfig, error)
func ProviderRegistryHash ¶ added in v0.6.0
func ProviderRegistryHash() string
ProviderRegistryHash returns a stable fingerprint for the set of registered providers.
func ReadModelRequestKey ¶
func ReadModelRequestKey(req ReadModelRequest) string
func ReadModelTemplatesFromRequest ¶
func ReadModelTemplatesFromRequest( req ReadModelRequest, disabledAccounts map[string]bool, ) map[string]core.UsageSnapshot
func ResolveAccounts ¶
func ResolveAccounts(cfg *config.Config) []core.AccountConfig
func ResolveSocketPath ¶
func ResolveSocketPath() string
func ResolveTelemetrySourceOptions ¶ added in v0.6.12
func ResolveTelemetrySourceOptions( source shared.TelemetrySource, requestedAccountID string, ) (shared.TelemetryCollectOptions, string, []string)
func SnapshotsHaveUsableData ¶
func SnapshotsHaveUsableData(snaps map[string]core.UsageSnapshot) bool
func SocketOwnerSummary ¶ added in v0.6.0
func StartBroadcaster ¶
func StartBroadcaster( ctx context.Context, rt *ViewRuntime, refreshInterval time.Duration, handler SnapshotHandler, stateHandler StateHandler, )
func StartupDiagnostics ¶
func StartupDiagnostics(manager ServiceManager, socketPath string) string
func TailTextLines ¶
func UninstallService ¶
Types ¶
type Client ¶
type Client struct {
SocketPath string
// contains filtered or unexported fields
}
func EnsureRunning ¶
func (*Client) HealthInfo ¶
func (c *Client) HealthInfo(ctx context.Context) (HealthResponse, error)
func (*Client) IngestHook ¶
func (*Client) ReadModel ¶
func (c *Client) ReadModel( ctx context.Context, request ReadModelRequest, ) (map[string]core.UsageSnapshot, error)
type DaemonState ¶
type DaemonState struct {
Status DaemonStatus
Message string
InstallHint string
}
func ClassifyEnsureError ¶
func ClassifyEnsureError(err error) DaemonState
type DaemonStatus ¶
type DaemonStatus int
const ( DaemonStatusUnknown DaemonStatus = iota DaemonStatusConnecting // attempting to reach daemon DaemonStatusNotInstalled // service not installed DaemonStatusStarting // service installed, waiting for health DaemonStatusRunning // healthy and current DaemonStatusOutdated // healthy but wrong version DaemonStatusError // unrecoverable error )
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
DaemonVersion string `json:"daemon_version,omitempty"`
APIVersion string `json:"api_version,omitempty"`
IntegrationVersion string `json:"integration_version,omitempty"`
ProviderRegistry string `json:"provider_registry_hash,omitempty"`
}
func WaitForHealthInfo ¶
type HookParseResult ¶ added in v0.6.12
type HookParseResult struct {
SourceName string
EffectiveAccountID string
Requests []telemetry.IngestRequest
Warnings []string
}
func ParseHookRequests ¶ added in v0.6.12
func ParseHookRequests(sourceName, accountID string, payload []byte) (HookParseResult, error)
type HookResponse ¶
type PollScheduler ¶ added in v0.8.0
type PollScheduler struct {
// contains filtered or unexported fields
}
PollScheduler manages per-provider adaptive backoff to reduce CPU usage when data sources are idle. Each account gets its own backoff state: when consecutive polls detect no changes, the effective interval increases in tiers up to a configurable cap.
func (*PollScheduler) EffectiveInterval ¶ added in v0.8.0
func (ps *PollScheduler) EffectiveInterval(accountID string) time.Duration
EffectiveInterval returns the current backoff interval for an account.
func (*PollScheduler) RecordPoll ¶ added in v0.8.0
func (ps *PollScheduler) RecordPoll(accountID string, changed bool)
RecordPoll records that a poll was executed. changed indicates whether the data actually differed from the previous poll.
func (*PollScheduler) ShouldPoll ¶ added in v0.8.0
func (ps *PollScheduler) ShouldPoll(accountID string, hasLocalDetector bool) bool
ShouldPoll returns true if enough time has elapsed for this account's current backoff tier. If the provider implements ChangeDetector, mark it accordingly for the correct cap.
func (*PollScheduler) SnapshotChanged ¶ added in v0.8.0
func (ps *PollScheduler) SnapshotChanged(accountID string, snap core.UsageSnapshot) bool
SnapshotChanged compares a snapshot's metrics to the previous hash for this account. Returns true if the snapshot is different (or first time seen).
type ReadModelAccount ¶
type ReadModelRequest ¶
type ReadModelRequest struct {
Accounts []ReadModelAccount `json:"accounts"`
ProviderLinks map[string]string `json:"provider_links"`
TimeWindow core.TimeWindow `json:"time_window,omitempty"`
}
func BuildReadModelRequest ¶
func BuildReadModelRequest( accounts []core.AccountConfig, providerLinks map[string]string, timeWindow core.TimeWindow, ) ReadModelRequest
func BuildReadModelRequestFromConfig ¶
func BuildReadModelRequestFromConfig() (ReadModelRequest, error)
type ReadModelResponse ¶
type ReadModelResponse struct {
Snapshots map[string]core.UsageSnapshot `json:"snapshots"`
}
type ServiceManager ¶
type ServiceManager struct {
Kind string
// contains filtered or unexported fields
}
func NewServiceManager ¶
func NewServiceManager(socketPath string) (ServiceManager, error)
func (ServiceManager) Install ¶
func (m ServiceManager) Install() error
func (ServiceManager) InstallHint ¶
func (m ServiceManager) InstallHint() string
func (ServiceManager) IsInstalled ¶
func (m ServiceManager) IsInstalled() bool
func (ServiceManager) IsSupported ¶
func (m ServiceManager) IsSupported() bool
func (ServiceManager) Start ¶
func (m ServiceManager) Start() error
func (ServiceManager) StatusHint ¶
func (m ServiceManager) StatusHint() string
func (ServiceManager) StderrLogPath ¶
func (m ServiceManager) StderrLogPath() string
func (ServiceManager) StdoutLogPath ¶
func (m ServiceManager) StdoutLogPath() string
func (ServiceManager) Uninstall ¶
func (m ServiceManager) Uninstall() error
type SnapshotFrame ¶ added in v0.6.12
type SnapshotFrame struct {
Snapshots map[string]core.UsageSnapshot
TimeWindow core.TimeWindow
}
type SnapshotHandler ¶
type SnapshotHandler func(SnapshotFrame)
type StateHandler ¶
type StateHandler func(DaemonState)
type ViewRuntime ¶
type ViewRuntime struct {
// contains filtered or unexported fields
}
func NewViewRuntime ¶
func NewViewRuntime( client *Client, socketPath string, verbose bool, ) *ViewRuntime
func (*ViewRuntime) CurrentClient ¶
func (r *ViewRuntime) CurrentClient() *Client
func (*ViewRuntime) EnsureClient ¶
func (r *ViewRuntime) EnsureClient(ctx context.Context) *Client
func (*ViewRuntime) ReadWithFallback ¶
func (r *ViewRuntime) ReadWithFallback(ctx context.Context) SnapshotFrame
func (*ViewRuntime) ReadWithFallbackForWindow ¶ added in v0.6.12
func (r *ViewRuntime) ReadWithFallbackForWindow(ctx context.Context, timeWindow core.TimeWindow) SnapshotFrame
func (*ViewRuntime) ResetEnsureThrottle ¶
func (r *ViewRuntime) ResetEnsureThrottle()
func (*ViewRuntime) SetClient ¶
func (r *ViewRuntime) SetClient(client *Client)
func (*ViewRuntime) SetTimeWindow ¶ added in v0.5.2
func (r *ViewRuntime) SetTimeWindow(tw core.TimeWindow)
func (*ViewRuntime) State ¶
func (r *ViewRuntime) State() DaemonState
func (*ViewRuntime) TimeWindow ¶ added in v0.5.2
func (r *ViewRuntime) TimeWindow() core.TimeWindow