metrics

package
v0.4.21 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

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

Counter represents a cumulative counter metric

func (*Counter) Add

func (c *Counter) Add(v uint64)

Add adds the given value to the counter

func (*Counter) Inc

func (c *Counter) Inc()

Inc increments the counter by 1

func (*Counter) Reset

func (c *Counter) Reset()

Reset resets the counter to zero

func (*Counter) Value

func (c *Counter) Value() uint64

Value returns the current counter value

type ExecutionMetrics

type ExecutionMetrics struct {
	AvgLatencyMs float64 `json:"avg_latency_ms"`
	P50LatencyMs float64 `json:"p50_latency_ms"`
	P95LatencyMs float64 `json:"p95_latency_ms"`
	SuccessRate  float64 `json:"success_rate"`
	TotalSuccess uint64  `json:"total_success"`
	TotalFailure uint64  `json:"total_failure"`
	Checkpoints  uint64  `json:"checkpoints_created"`
}

ExecutionMetrics represents execution layer snapshot

type Gauge

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

Gauge represents a point-in-time gauge metric

func (*Gauge) Add

func (g *Gauge) Add(v int64)

Add adds the given value to the gauge

func (*Gauge) Dec

func (g *Gauge) Dec()

Dec decrements the gauge by 1

func (*Gauge) Inc

func (g *Gauge) Inc()

Inc increments the gauge by 1

func (*Gauge) Set

func (g *Gauge) Set(v int64)

Set sets the gauge to the given value

func (*Gauge) Value

func (g *Gauge) Value() int64

Value returns the current gauge value

type Histogram

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

Histogram represents a histogram metric for distribution tracking

func NewHistogram

func NewHistogram(buckets []float64) *Histogram

NewHistogram creates a new histogram with custom buckets

func (*Histogram) Avg

func (h *Histogram) Avg() float64

Avg returns the average of all observations

func (*Histogram) Count

func (h *Histogram) Count() int64

Count returns the total observation count

func (*Histogram) Max

func (h *Histogram) Max() float64

Max returns the maximum observation

func (*Histogram) Min

func (h *Histogram) Min() float64

Min returns the minimum observation

func (*Histogram) Observe

func (h *Histogram) Observe(v float64)

Observe records a single observation

func (*Histogram) Percentile

func (h *Histogram) Percentile(p float64) float64

Percentile calculates the p-th percentile

func (*Histogram) Sum

func (h *Histogram) Sum() float64

Sum returns the sum of all observations

type MemoryMetrics

type MemoryMetrics struct {
	SizeBytes         int64   `json:"size_bytes"`
	AvgQueryLatencyMs float64 `json:"avg_query_latency_ms"`
	P95LatencyMs      float64 `json:"p95_latency_ms"`
	CacheHitRate      float64 `json:"cache_hit_rate"`
	TotalRetrievals   uint64  `json:"total_retrievals"`
}

MemoryMetrics represents memory layer snapshot

type Metrics

type Metrics struct {
	// Perception layer metrics
	PerceptionLatency    *Histogram `json:"perception_latency"`
	IntentClassification *Counter   `json:"intent_classification"`

	// Decision layer metrics
	PlanningLatency *Histogram `json:"planning_latency"`
	AvgStepsPerPlan *Gauge     `json:"avg_steps_per_plan"`
	PlanAdjustments *Counter   `json:"plan_adjustments"`

	// Execution layer metrics
	ExecutionLatency    *Histogram `json:"execution_latency"`
	ExecutionSuccess    *Counter   `json:"execution_success"`
	ExecutionFailure    *Counter   `json:"execution_failure"`
	CheckpointsCreated  *Counter   `json:"checkpoints_created"`
	CheckpointsRestored *Counter   `json:"checkpoints_restored"`

	// Memory metrics
	MemorySize           *Gauge     `json:"memory_size_bytes"`
	FTSQueryLatency      *Histogram `json:"fts_query_latency"`
	MemoryRetrievalCount *Counter   `json:"memory_retrieval_count"`
	CacheHits            *Counter   `json:"cache_hits"`
	CacheMisses          *Counter   `json:"cache_misses"`

	// Plugin metrics
	PluginLoadCount  *Counter `json:"plugin_load_count"`
	PluginUsageCount *Counter `json:"plugin_usage_count"`
	PluginErrors     *Counter `json:"plugin_errors"`

	// Skill metrics
	SkillsCreated     *Counter `json:"skills_created"`
	SkillUsageCount   *Counter `json:"skill_usage_count"`
	PatternDetections *Counter `json:"pattern_detections"`

	// Trigger metrics
	NudgeCount      *Counter `json:"nudge_count"`
	NudgeAcceptance *Counter `json:"nudge_acceptance"`

	// Review metrics
	ReviewCount *Counter `json:"review_count"`

	// System metrics
	ActiveGoroutines *Gauge `json:"active_goroutines"`
	Uptime           *Gauge `json:"uptime_seconds"`

	// Intent distribution
	IntentDistribution map[string]*Counter
	// contains filtered or unexported fields
}

Metrics represents a collection of all metrics

func NewMetrics

func NewMetrics() *Metrics

NewMetrics creates a new metrics collector

func (*Metrics) ExportJSON

func (m *Metrics) ExportJSON() ([]byte, error)

ExportJSON exports metrics as JSON

func (*Metrics) ExportPrometheus

func (m *Metrics) ExportPrometheus() string

ExportPrometheus exports metrics in Prometheus text format

func (*Metrics) RecordCheckpoint

func (m *Metrics) RecordCheckpoint(created bool)

RecordCheckpoint records checkpoint operations

func (*Metrics) RecordExecution

func (m *Metrics) RecordExecution(duration time.Duration, success bool)

RecordExecution records execution layer metrics

func (*Metrics) RecordMemory

func (m *Metrics) RecordMemory(size int64, queryDuration time.Duration, cacheHit bool)

RecordMemory records memory operation metrics

func (*Metrics) RecordNudge

func (m *Metrics) RecordNudge(accepted bool)

RecordNudge records nudge metrics

func (*Metrics) RecordPerception

func (m *Metrics) RecordPerception(duration time.Duration, intent string)

RecordPerception records perception layer metrics

func (*Metrics) RecordPlanAdjustment

func (m *Metrics) RecordPlanAdjustment()

RecordPlanAdjustment records a plan adjustment

func (*Metrics) RecordPlanning

func (m *Metrics) RecordPlanning(duration time.Duration, steps int)

RecordPlanning records planning layer metrics

func (*Metrics) RecordPlugin

func (m *Metrics) RecordPlugin(operation string, success bool)

RecordPlugin records plugin metrics

func (*Metrics) RecordReview

func (m *Metrics) RecordReview()

RecordReview records review metrics

func (*Metrics) RecordSkill

func (m *Metrics) RecordSkill(operation string)

RecordSkill records skill metrics

func (*Metrics) Reset

func (m *Metrics) Reset()

Reset resets all metrics

func (*Metrics) Snapshot

func (m *Metrics) Snapshot() *MetricsSnapshot

Snapshot returns a point-in-time snapshot of all metrics

func (*Metrics) UpdateSystemMetrics

func (m *Metrics) UpdateSystemMetrics()

UpdateSystemMetrics updates system-level metrics

type MetricsSnapshot

type MetricsSnapshot struct {
	Timestamp          time.Time         `json:"timestamp"`
	Perception         PerceptionMetrics `json:"perception"`
	Planning           PlanningMetrics   `json:"planning"`
	Execution          ExecutionMetrics  `json:"execution"`
	Memory             MemoryMetrics     `json:"memory"`
	Plugins            PluginMetrics     `json:"plugins"`
	Skills             SkillMetrics      `json:"skills"`
	Triggers           TriggerMetrics    `json:"triggers"`
	IntentDistribution map[string]uint64 `json:"intent_distribution"`
}

MetricsSnapshot represents a point-in-time snapshot of metrics

type PerceptionMetrics

type PerceptionMetrics struct {
	AvgLatencyMs    float64 `json:"avg_latency_ms"`
	P50LatencyMs    float64 `json:"p50_latency_ms"`
	P95LatencyMs    float64 `json:"p95_latency_ms"`
	P99LatencyMs    float64 `json:"p99_latency_ms"`
	TotalClassified uint64  `json:"total_classified"`
}

PerceptionMetrics represents perception layer snapshot

type PlanningMetrics

type PlanningMetrics struct {
	AvgLatencyMs     float64 `json:"avg_latency_ms"`
	P50LatencyMs     float64 `json:"p50_latency_ms"`
	P95LatencyMs     float64 `json:"p95_latency_ms"`
	AvgSteps         int64   `json:"avg_steps"`
	TotalAdjustments uint64  `json:"total_adjustments"`
}

PlanningMetrics represents planning layer snapshot

type PluginMetrics

type PluginMetrics struct {
	TotalLoads  uint64 `json:"total_loads"`
	TotalUsages uint64 `json:"total_usages"`
	TotalErrors uint64 `json:"total_errors"`
}

PluginMetrics represents plugin layer snapshot

type SkillMetrics

type SkillMetrics struct {
	TotalCreated  uint64 `json:"total_created"`
	TotalUsages   uint64 `json:"total_usages"`
	PatternsFound uint64 `json:"patterns_found"`
}

SkillMetrics represents skill layer snapshot

type TriggerMetrics

type TriggerMetrics struct {
	TotalNudges    uint64  `json:"total_nudges"`
	TotalAccepted  uint64  `json:"total_accepted"`
	AcceptanceRate float64 `json:"acceptance_rate"`
}

TriggerMetrics represents trigger layer snapshot

Jump to

Keyboard shortcuts

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