feat: add AI APM module for AI/LLM call telemetry
- internal/aiapm/types.go: AICallRecord, filter, summary, and stats types - internal/aiapm/pricing.go: vendor pricing tables (Anthropic, OpenAI, Google, Mistral, DeepSeek, Groq) - internal/aiapm/store.go: PostgreSQL storage with batch insert, filtered queries, aggregations, timeseries - internal/aiapm/collector.go: async collector with buffered channel and background batch writer - internal/api/aiapm_handlers.go: Fiber route handlers for ingest, summary, models, vendors, costs, calls, pricing - cmd/server/main.go: register AI APM routes and create ai_calls table at startup
This commit is contained in:
@@ -12,6 +12,8 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/bigtux/ophion/internal/aiapm"
|
||||
aiapmapi "github.com/bigtux/ophion/internal/api"
|
||||
"github.com/bigtux/ophion/internal/auth"
|
||||
"github.com/bigtux/ophion/internal/otel"
|
||||
"github.com/bigtux/ophion/internal/security"
|
||||
@@ -107,6 +109,12 @@ func main() {
|
||||
} else {
|
||||
log.Println("✓ Connected to PostgreSQL")
|
||||
initSchema(db)
|
||||
// Initialize AI APM table
|
||||
if err := aiapm.CreateTable(db); err != nil {
|
||||
log.Printf("⚠ Failed to create AI APM table: %v", err)
|
||||
} else {
|
||||
log.Println("✓ AI APM table initialized")
|
||||
}
|
||||
// Create default admin user
|
||||
if err := auth.CreateDefaultAdmin(db); err != nil {
|
||||
log.Printf("⚠ Failed to create default admin: %v", err)
|
||||
@@ -335,6 +343,9 @@ func (s *Server) setupRoutes() {
|
||||
// Dashboard
|
||||
protected.Get("/dashboard/overview", s.getDashboardOverview)
|
||||
|
||||
// AI APM routes
|
||||
aiapmapi.RegisterAIAPMRoutes(protected, s.db)
|
||||
|
||||
// User info
|
||||
protected.Get("/me", s.authHandler.Me)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user