Documentation
¶
Overview ¶
Package metrics provides application metrics collection.
Index ¶
- Variables
- func DefaultBuckets() []float64
- func PrometheusHandler() func(w io.Writer)
- func RecordAgentSteps(steps float64)
- func RecordCost(model, feature string, cents uint64)
- func RecordSkillCall(skillName string, durationSec float64, success bool)
- func RecordTTFT(seconds float64)
- func RecordThinkFlowExecution(durationSec float64)
- func RecordThinkFlowRetry()
- func RecordTokens(model, tokenType, feature string, count uint64)
- func RecordToolCall(agentType, status string)
- func RecordUserFeedback(feedbackType string)
- type Counter
- type Gauge
- type Histogram
- type HistogramSnapshot
- type Registry
- func (r *Registry) GetCounter(name string) *Counter
- func (r *Registry) GetGauge(name string) *Gauge
- func (r *Registry) GetHistogram(name string) *Histogram
- func (r *Registry) RegisterCounter(c *Counter)
- func (r *Registry) RegisterGauge(g *Gauge)
- func (r *Registry) RegisterHistogram(h *Histogram)
- func (r *Registry) Snapshot() *Snapshot
- func (r *Registry) WritePrometheus(w io.Writer) error
- type Snapshot
- type Timer
Constants ¶
This section is empty.
Variables ¶
var ( // HTTP metrics HTTPRequestsTotal = NewCounter("http_requests_total") HTTPRequestDuration = NewHistogram("http_request_duration_seconds", DefaultBuckets()) HTTPActiveConnections = NewGauge("http_active_connections") // LLM metrics LLMRequestsTotal = NewCounter("llm_requests_total") LLMRequestDuration = NewHistogram("llm_request_duration_seconds", DefaultBuckets()) LLMTokensTotal = NewCounter("llm_tokens_total") LLMSlowRequests = NewCounter("llm_slow_requests_total") // Database metrics DBQueriesTotal = NewCounter("db_queries_total") DBQueryDuration = NewHistogram("db_query_duration_seconds", DefaultBuckets()) DBConnectionsOpen = NewGauge("db_connections_open") // Memory metrics MemorySessionsActive = NewGauge("memory_sessions_active") MemoryMessagesTotal = NewCounter("memory_messages_total") // Workforce metrics WorkforceActive = NewGauge("workforce_active") WorkforceTasksTotal = NewCounter("workforce_tasks_total") // Token consumption metrics // Labels: model, type (input/output), feature AITokensTotal = NewCounter("ai_tokens_total") // Cost tracking in cents (for budget monitoring) // Labels: model, feature AICostCents = NewCounter("ai_cost_cents") // Time to first token for streaming responses AITimeToFirstToken = NewHistogram("ai_time_to_first_token_seconds", []float64{0.1, 0.25, 0.5, 1, 2, 5, 10}) // Agent execution metrics // Labels: agent_type, status (success/failure) AgentToolCallsTotal = NewCounter("agent_tool_calls_total") AgentStepsPerTask = NewHistogram("agent_steps_per_task", []float64{1, 2, 3, 5, 10, 20, 50}) // User feedback metrics // Labels: feedback_type (thumbs_up/thumbs_down/edit) AIUserFeedbackTotal = NewCounter("ai_user_feedback_total") // ThinkFlow metrics ThinkFlowExecutionsTotal = NewCounter("thinkflow_executions_total") ThinkFlowDuration = NewHistogram("thinkflow_duration_seconds", DefaultBuckets()) ThinkFlowRetriesTotal = NewCounter("thinkflow_retries_total") // Skill execution metrics SkillCallsTotal = NewCounter("skill_calls_total") SkillCallDuration = NewHistogram("skill_call_duration_seconds", DefaultBuckets()) SkillFailuresTotal = NewCounter("skill_failures_total") )
var DefaultRegistry = NewRegistry()
DefaultRegistry is the global default registry.
Functions ¶
func DefaultBuckets ¶
func DefaultBuckets() []float64
DefaultBuckets returns default latency buckets in seconds.
func PrometheusHandler ¶
PrometheusHandler returns a http.HandlerFunc for /metrics endpoint.
func RecordAgentSteps ¶
func RecordAgentSteps(steps float64)
RecordAgentSteps records the number of steps taken to complete a task.
func RecordCost ¶
RecordCost records cost in cents for an AI request.
func RecordSkillCall ¶
RecordSkillCall records a skill invocation.
func RecordTTFT ¶
func RecordTTFT(seconds float64)
RecordTTFT records time to first token for a streaming response.
func RecordThinkFlowExecution ¶
func RecordThinkFlowExecution(durationSec float64)
RecordThinkFlowExecution records a ThinkFlow execution.
func RecordThinkFlowRetry ¶
func RecordThinkFlowRetry()
RecordThinkFlowRetry records a ThinkFlow retry.
func RecordTokens ¶
RecordTokens records token consumption for an AI request.
func RecordToolCall ¶
func RecordToolCall(agentType, status string)
RecordToolCall records a tool/skill call by an agent.
func RecordUserFeedback ¶
func RecordUserFeedback(feedbackType string)
RecordUserFeedback records user feedback on AI response.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a monotonically increasing counter.
func NewCounter ¶
NewCounter creates a new counter with name and optional tags.
func (*Counter) WithLabels ¶
WithLabels returns a new counter with additional labels.
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge is a value that can increase and decrease.
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram tracks distribution of values.
func Histogram_ ¶
Histogram creates or returns a histogram.
func NewHistogram ¶
NewHistogram creates a new histogram with name and buckets.
type HistogramSnapshot ¶
HistogramSnapshot contains histogram data.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered metrics.
func (*Registry) GetCounter ¶
GetCounter returns a counter by name.
func (*Registry) GetHistogram ¶
GetHistogram returns a histogram by name.
func (*Registry) RegisterCounter ¶
RegisterCounter registers a counter in the registry.
func (*Registry) RegisterGauge ¶
RegisterGauge registers a gauge in the registry.
func (*Registry) RegisterHistogram ¶
RegisterHistogram registers a histogram in the registry.