LLM Observability Patterns
Skill4 starsChanged 10 months agoMITView on GitHub
Tracing and monitoring patterns for LLM applications using Langfuse, Phoenix, and OpenLLMetry. Use when adding observability, debugging AI calls, or tracking costs.
- Reads credentials
- Installs packages
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- Claude Agent SDK PatternsSkill
- delegation-templatesSkill
- deploymentSkill
- frontend-patternsSkill
- Google ADK PatternsSkill
- LLM Evaluation PatternsSkill
- memory-workflowSkill
- orchestrator-workflowsSkill
- react-native-best-practicesSkill
- skill-creatorSkill
- testing-strategySkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 92
Decision: Use Langfuse Cloud for development and most production.
- Very specific: line 121
Use @observe() on route handlers or service functions
- Distinctive: line 126
Use manual spans for tool calls
- Very specific: line 130
Use @observe() on functions calling Claude
- Very specific: line 177
Flushing: Call langfuse.flush() before shutdown in short-lived processes
- Distinctive: line 179
Data privacy: Never log PII in inputs/outputs.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
LLM Observability Patterns - Quick Reference
This skill covers three complementary observability platforms:
- Langfuse - Production-focused, cloud-first, team collaboration
- Phoenix - Local-first, combined tracing+evaluation, experimentation
- OpenLLMetry - OpenTelemetry-based, export to any OTLP backend (Datadog, GCP, etc.)
Packages: pip install langfuse | pip install arize-phoenix | pip install traceloop-sdk
Modules
Langfuse (Production)
- 01-langfuse-setup.md - Setup & Configuration
- Installation and environment setup
- Cloud vs self-hosted deployment
- Project conventions
- 02-tracing-patterns.md - Tracing Patterns
- @observe decorator usage
- Manual spans and generations
- Integration with OpenAI, Anthropic, ADK
- 03-cost-tracking.md - Cost & Evaluation
- Token usage tracking
- Cost monitoring and budgets
- Scores and user feedback
Phoenix (Local Development)
- 04-phoenix-local-dev.md - Local-First Observability
- Quick local server setup
- OpenTelemetry-based instrumentation
- Built-in LLM evaluators
- Notebook integration
OpenLLMetry (OpenTelemetry Export)
- 05-openllmetry-otel.md - OpenTelemetry Integration
- Export to any OTLP backend (Datadog, Honeycomb, Grafana)
- GCP Cloud Trace integration
- OpenTelemetry semantic conventions for LLMs
- Auto-instrumentation for major providers
When to Use Which Platform
| Need | Langfuse | Phoenix | OpenLLMetry | Recommendation |
| Local experimentation | OK | Best | OK | Phoenix |
| Production monitoring | Best | OK | Good | Langfuse or OpenLLMetry |
| Team collaboration | Best | Limited | Via backend | Langfuse |
| Built-in LLM evals | No | Yes | No | Phoenix |
| Existing OTEL infra | No | Yes | Best | OpenLLMetry |
| GCP Cloud Trace | No | Manual | Native | OpenLLMetry |
| Datadog/Honeycomb | No | No | Native | OpenLLMetry |
| Cost tracking | Best | Basic | Via backend | Langfuse |
| No account/setup | No | Yes | No | Phoenix |
Rule of thumb:
- Phoenix for dev/experimentation
- Langfuse for LLM-focused production monitoring
- OpenLLMetry when you have existing OTEL infrastructure or need GCP Cloud Trace
Decision: Cloud vs Self-Hosted
| Factor | Langfuse Cloud | Self-Hosted |
| Setup | Instant (sign up) | Docker Compose or K8s |
| Cost | Free tier + paid plans | Infrastructure cost |
| Data privacy | Data on Langfuse servers | Full data control |
| Maintenance | Managed by Langfuse | You maintain |
| Recommendation | Start here, migrate if needed | Regulated industries |
Decision: Use Langfuse Cloud for development and most production. Self-host only if data residency requirements mandate it.
Quick Start Pattern
# 1. Install
# pip install langfuse
# 2. Set environment variables
# LANGFUSE_PUBLIC_KEY="pk-lf-..."
# LANGFUSE_SECRET_KEY="sk-lf-..."
# LANGFUSE_HOST="https://cloud.langfuse.com" # or self-hosted URL
# 3. Use @observe decorator
from langfuse import observe
@observe()
def my_llm_function(prompt: str) -> str:
# Your LLM call here
return responseIntegration with Our Stack
With FastAPI
- Use
@observe()on route handlers or service functions - Flush on shutdown:
langfuse.flush()in lifespan
With Google ADK
- Wrap agent execution with
@observe() - Use manual spans for tool calls
- See 02-tracing-patterns.md for patterns
With Claude SDK
- Use
@observe()on functions calling Claude - Manual generation spans for detailed tracking
What to Trace
Always trace:
- LLM API calls (input, output, model, tokens)
- Agent tool invocations
- Retrieval/RAG operations
- Error states and retries
Metadata to include:
user_id- For per-user analyticssession_id- Group related requeststags- Categorize by feature/endpointversion- Track prompt/model versions
Project Conventions
Span Naming
# Pattern: {component}-{operation}
chat-completion
rag-retrieval
agent-tool-callMetadata Structure
{
"user_id": "user-123",
"session_id": "session-abc",
"environment": "production",
"version": "v1.2.0",
"feature": "chat-assistant"
}Common Gotchas
- Async context:
@observe()works with async functions automatically - Flushing: Call
langfuse.flush()before shutdown in short-lived processes - Batching: Langfuse batches events; traces may not appear instantly
- Data privacy: Never log PII in inputs/outputs; use filtering
- Cost calculation: Requires model definitions in Langfuse for auto-cost
Context7 Lookup Topics
For current API patterns, use Context7:
Langfuse:
get-library-docs: /langfuse/langfuse-docs (topic: "observe decorator")
get-library-docs: /langfuse/langfuse-docs (topic: "cost tracking usage")
get-library-docs: /langfuse/langfuse-docs (topic: "scores evaluation")
get-library-docs: /langfuse/langfuse-docs (topic: "openai integration")Phoenix:
get-library-docs: /arize-ai/phoenix (topic: "launch app server")
get-library-docs: /arize-ai/phoenix (topic: "instrumentation openai")
get-library-docs: /arize-ai/phoenix (topic: "evals llm classify")
get-library-docs: /arize-ai/phoenix (topic: "experiments datasets")OpenLLMetry:
get-library-docs: /traceloop/openllmetry (topic: "traceloop sdk init")
get-library-docs: /traceloop/openllmetry (topic: "instrumentation openai anthropic")
get-library-docs: /traceloop/openllmetry (topic: "workflow decorator")Related Skills
- llm-evaluation - DeepEval patterns for testing
- google-adk-patterns - ADK agent patterns
Last Updated: 2025-12-26
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

