Documentation
¶
Index ¶
- type UsageCollectorClient
- func (c *UsageCollectorClient) Close() error
- func (c *UsageCollectorClient) RecordUsage(userID string, actionID string, vendor string, model string, ...) error
- func (c *UsageCollectorClient) SetProjectID(projectID string)
- func (c *UsageCollectorClient) SetProjectResolver(fn func(meta map[string]string) string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UsageCollectorClient ¶
type UsageCollectorClient struct {
// contains filtered or unexported fields
}
UsageCollectorClient is a client for sending LLM usage events to the usage collector service It implements llm.UsageTracker interface
func NewUsageCollectorClient ¶
func NewUsageCollectorClient(host, projectID string, useTLS bool, token string) (*UsageCollectorClient, error)
NewUsageCollectorClient creates a new usage collector client If host is empty, returns nil (usage collection disabled) projectID is the default project events are attributed to; a non-empty token is sent as a bearer token on every call.
func (*UsageCollectorClient) Close ¶
func (c *UsageCollectorClient) Close() error
Close flushes held and queued events (up to a few seconds), then closes the connection.
func (*UsageCollectorClient) RecordUsage ¶
func (c *UsageCollectorClient) RecordUsage( userID string, actionID string, vendor string, model string, usage llm.TokensUsage, durationMs int64, costNanoUSD int64, status usagev1.Status, meta map[string]string, ) error
RecordUsage queues a usage event for the collector. It returns an error only when validation fails; delivery is asynchronous and retried.
func (*UsageCollectorClient) SetProjectID ¶
func (c *UsageCollectorClient) SetProjectID(projectID string)
SetProjectID sets the project ID (App UUID) for usage tracking
func (*UsageCollectorClient) SetProjectResolver ¶
func (c *UsageCollectorClient) SetProjectResolver(fn func(meta map[string]string) string)
SetProjectResolver installs a per-event project resolver.