feat: AI APM module — LLM call telemetry & analytics #1

Open
rainbow wants to merge 1 commits from feat/ai-apm into main
First-time contributor

AI APM for Ophion

Extends Ophion with AI/LLM observability. Every AI call from any product (Cute Kiwi, Sentinela, etc.) gets tracked, stored, and analyzed.

New Files

  • internal/aiapm/types.go — AI call record types + analytics aggregation types
  • internal/aiapm/pricing.go — Pricing tables for 25+ models (Anthropic, OpenAI, Google, Mistral, DeepSeek, Groq)
  • internal/aiapm/store.go — PostgreSQL storage (batch inserts, filtered queries, timeseries, aggregations)
  • internal/aiapm/collector.go — Async collector with buffered channel (5000 cap), batch flush every 500ms or 100 records
  • internal/api/aiapm_handlers.go — 7 REST endpoints under /api/v1/ai-apm/

Endpoints

  • POST /api/v1/ai-apm/ingest — receive AI call records (single or batch)
  • GET /api/v1/ai-apm/summary — usage summary (calls, tokens, cost)
  • GET /api/v1/ai-apm/models — per-model breakdown
  • GET /api/v1/ai-apm/vendors — per-vendor breakdown
  • GET /api/v1/ai-apm/costs — cost timeseries
  • GET /api/v1/ai-apm/calls — recent calls (paginated)
  • GET /api/v1/ai-apm/pricing — current pricing table

Modified

  • cmd/server/main.go — registers AI APM routes, creates table at startup

Build

go build ./... passes clean.


Every AI call goes through the gateway. No exceptions. — Bezos Mandate

## AI APM for Ophion Extends Ophion with AI/LLM observability. Every AI call from any product (Cute Kiwi, Sentinela, etc.) gets tracked, stored, and analyzed. ### New Files - `internal/aiapm/types.go` — AI call record types + analytics aggregation types - `internal/aiapm/pricing.go` — Pricing tables for 25+ models (Anthropic, OpenAI, Google, Mistral, DeepSeek, Groq) - `internal/aiapm/store.go` — PostgreSQL storage (batch inserts, filtered queries, timeseries, aggregations) - `internal/aiapm/collector.go` — Async collector with buffered channel (5000 cap), batch flush every 500ms or 100 records - `internal/api/aiapm_handlers.go` — 7 REST endpoints under `/api/v1/ai-apm/` ### Endpoints - `POST /api/v1/ai-apm/ingest` — receive AI call records (single or batch) - `GET /api/v1/ai-apm/summary` — usage summary (calls, tokens, cost) - `GET /api/v1/ai-apm/models` — per-model breakdown - `GET /api/v1/ai-apm/vendors` — per-vendor breakdown - `GET /api/v1/ai-apm/costs` — cost timeseries - `GET /api/v1/ai-apm/calls` — recent calls (paginated) - `GET /api/v1/ai-apm/pricing` — current pricing table ### Modified - `cmd/server/main.go` — registers AI APM routes, creates table at startup ### Build `go build ./...` passes clean. --- > Every AI call goes through the gateway. No exceptions. — Bezos Mandate
rainbow added 1 commit 2026-02-08 08:14:16 +00:00
- 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 pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/ai-apm:feat/ai-apm
git checkout feat/ai-apm
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bigtux/ophion#1