agentleFS
sagullapallisagullapalli/claude-code-setup/.claude/skills/llm-observability/SKILL.md

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

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
  1. Distinctive:

    Decision: Use Langfuse Cloud for development and most production.

    line 92
  2. Very specific:

    Use @observe() on route handlers or service functions

    line 121
  3. Distinctive:

    Use manual spans for tool calls

    line 126
  4. Very specific:

    Use @observe() on functions calling Claude

    line 130
  5. Very specific:

    Flushing: Call langfuse.flush() before shutdown in short-lived processes

    line 177
  6. Distinctive:

    Data privacy: Never log PII in inputs/outputs.

    line 179

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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)

  1. 01-langfuse-setup.md - Setup & Configuration
    • Installation and environment setup
    • Cloud vs self-hosted deployment
    • Project conventions
  2. 02-tracing-patterns.md - Tracing Patterns
    • @observe decorator usage
    • Manual spans and generations
    • Integration with OpenAI, Anthropic, ADK
  3. 03-cost-tracking.md - Cost & Evaluation
    • Token usage tracking
    • Cost monitoring and budgets
    • Scores and user feedback

Phoenix (Local Development)

  1. 04-phoenix-local-dev.md - Local-First Observability
    • Quick local server setup
    • OpenTelemetry-based instrumentation
    • Built-in LLM evaluators
    • Notebook integration

OpenLLMetry (OpenTelemetry Export)

  1. 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

NeedLangfusePhoenixOpenLLMetryRecommendation
Local experimentationOKBestOKPhoenix
Production monitoringBestOKGoodLangfuse or OpenLLMetry
Team collaborationBestLimitedVia backendLangfuse
Built-in LLM evalsNoYesNoPhoenix
Existing OTEL infraNoYesBestOpenLLMetry
GCP Cloud TraceNoManualNativeOpenLLMetry
Datadog/HoneycombNoNoNativeOpenLLMetry
Cost trackingBestBasicVia backendLangfuse
No account/setupNoYesNoPhoenix

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

FactorLangfuse CloudSelf-Hosted
SetupInstant (sign up)Docker Compose or K8s
CostFree tier + paid plansInfrastructure cost
Data privacyData on Langfuse serversFull data control
MaintenanceManaged by LangfuseYou maintain
RecommendationStart here, migrate if neededRegulated 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 response

Integration 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 analytics
  • session_id - Group related requests
  • tags - Categorize by feature/endpoint
  • version - Track prompt/model versions

Project Conventions

Span Naming

# Pattern: {component}-{operation}
chat-completion
rag-retrieval
agent-tool-call

Metadata Structure

{
    "user_id": "user-123",
    "session_id": "session-abc",
    "environment": "production",
    "version": "v1.2.0",
    "feature": "chat-assistant"
}

Common Gotchas

  1. Async context: @observe() works with async functions automatically
  2. Flushing: Call langfuse.flush() before shutdown in short-lived processes
  3. Batching: Langfuse batches events; traces may not appear instantly
  4. Data privacy: Never log PII in inputs/outputs; use filtering
  5. 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.