otellix
OpenTelemetry-native LLM observability and budget guardrails for cost-constrained production environments
About otellix
Otellix
Stop the LLM Bill Shock. Production-grade observability for Go backends â built on OpenTelemetry.

đ¸ The Problem: "Bill Shock" is Real
Most LLM observability tools tell you what you spent after the money is gone. In production, a recursive prompt loop or a single "power user" can rack up thousands in costs before your billing alerts even trigger.
Otellix is different. It brings real-time cost enforcement to the application layer.
⥠Key Features
- âī¸ LangChainGo Integration: Drop-in
callbacks.Handlerfor LangChainGo. Automatic token, cost, and span capture for chains. - đ Zero-Config Attribution: Automatically capture
user_idandproject_idfrom Gin/Echo middleware. No more manual context plumbing. - đī¸ Redis Budget Store: Distributed budget enforcement for high-availability production clusters.
- đ Go-Native & High-Performance: Built for Go 1.22+ using native streaming and OpenTelemetry.
- đ Standard-Compliant (OTel): 100% OTel compliant. Works with Jaeger, Honeycomb, Prometheus, and Grafana.
- đ Prompt Caching ROI: Track exactly how much you save with Anthropic/OpenAI prompt caching.
đ Quick Start
go get github.com/oluwajubelo1/otellix
đšī¸ Try it Locally (Docker)
Want to see the full stack (Prometheus + Grafana) in action? Run our one-liner demo:
curl -sL https://raw.githubusercontent.com/oluwajubelo1/otellix/main/scripts/demo.sh | bash
1. Simple Tracing
Wrap your provider calls to get instant cost attribution and standard OTel spans.
p := openai.New()
result, err := otellix.Trace(ctx, p, params,
otellix.WithUserID("user_456"),
)
2. LangChainGo Integration
Just add the Otellix handler to your LLM configuration.
import "github.com/oluwajubelo1/otellix/integrations/langchaingo"
handler := langchaingo.NewOtellixHandler(
langchaingo.WithProvider("openai"), // required for accurate llm.cost_usd
langchaingo.WithModel("gpt-4o"),
)
p, _ := openai.New(openai.WithCallback(handler))
// Automatically captures token usage, cost, and spans.
res, err := p.GenerateContent(ctx, parts)
The handler records llm.* attributes on a span in the context, or creates its
own llm.call span if none exists, so telemetry is always captured. Set
WithProvider/WithModel (LangChainGo doesn't expose them in its callbacks)
to enable cost tracking.
3. Middleware Attribution
Stop manually passing IDs. Use our middleware to discover identity from headers/JWTs.
import otellixmw "github.com/oluwajubelo1/otellix/middleware"
r := gin.Default()
r.Use(otellixmw.GinMiddleware()) // Automatically populates context with User/Project IDs
4. Local Development
Two dev modes help you see traces while building:
shutdown := otellix.SetupDev() // (1) Pretty summary + raw OTel span JSON
defer shutdown()
shutdown := otellix.SetupDevConsole() // (2) Pretty summary only â clean terminal
defer shutdown()
SetupDev()configures an OpenTelemetry stdout trace exporter (human-readable summary and the raw span JSON) â best for inspecting the exact span payload.SetupDevConsole()prints only the one-line[otellix]summary per call and leaves your existingTracerProvideruntouched â ideal for demos and presentations.RegisterDevPrinter()enables just the summary printer when you already have your ownTracerProviderconfigured.
đ Standardized OTel Attributes
Otellix populates your spans with industry-standard attributes:
| Attribute | Description |
|---|---|
llm.provider | The LLM provider (OpenAI, Anthropic, etc.) |
llm.model | The model used (e.g. claude-sonnet-4-6) |
llm.input_tokens / llm.output_tokens | Token usage for the call |
llm.cache_read_tokens | Tokens served from provider cache (Savings!) |
llm.cost_usd | Real-time USD cost of the call |
đī¸ Supported Providers
Provider wrappers (drop-in Call/Stream):
- Anthropic: Claude Opus/Sonnet/Haiku families with full Prompt Caching metrics.
- OpenAI: GPT-5.x, GPT-4.x, o-series, gpt-oss with caching support.
- Google Gemini: Gemini 3.x, 2.5, 2.0 & 1.5 Pro/Flash.
- Ollama: Local models with zero-dependency streaming.
Pricing-only support (built-in cost table for llm.cost_usd; bring your own provider/API): Kimi (Moonshot), DeepSeek, Qwen, GLM, ERNIE, Hunyuan, Mistral, Grok, plus every model above â 130+ models total. See docs/providers.md.
đ Deep Dives
- Architecture â How Otellix fits into the OTel ecosystem.
- Budget Guardrails â Redis & InMemory stores.
- Integrations â LangChainGo setup.
- Middleware & Identity â Zero-config attribution.
- Prompt Caching â ROI analysis and tracking.
đ¤ Contributing
We love stars and contributions! Please see CONTRIBUTING.md. Licensed under MIT.
Frequently Asked Questions
What is otellix?
otellix is a Artificial Intelligence library for the Go programming language. OpenTelemetry-native LLM observability and budget guardrails for cost-constrained production environments
How do I install otellix?
Install otellix with the Go module system using `go get oluwajubelo1/otellix`. Check the repository for the current installation instructions.
What category does otellix belong to?
otellix is listed under Artificial Intelligence, specifically Artificial Intelligence.