首页/AI 系统可观测与 SRE/langfuse-observability
L

langfuse-observability

by @langfusev
4.6(24)

使用Langfuse追踪工具,为LLM应用提供可观测性,遵循最佳实践并根据用例进行定制。

langfusellm-observabilityai-monitoringtrace-managementGitHub
安装方式
npx skills add https://github.com/langfuse/skills --skill langfuse-observability
compare_arrows

Before / After 效果对比

1 组
使用前

缺乏统一的追踪工具,难以监控LLM应用的运行状态和性能瓶颈。排查问题耗时费力,影响开发效率和用户体验。

使用后

借助Langfuse,轻松实现LLM应用端到端的可观测性。快速识别并解决潜在问题,优化应用性能,确保稳定运行。

SKILL.md

langfuse-observability

Langfuse Observability

Instrument LLM applications with Langfuse tracing, following best practices and tailored to your use case.

When to Use

  • Setting up Langfuse in a new project

  • Auditing existing Langfuse instrumentation

  • Adding observability to LLM calls

Workflow

1. Assess Current State

Check the project:

  • Is Langfuse SDK installed?

  • What LLM frameworks are used? (OpenAI SDK, LangChain, LlamaIndex, Vercel AI SDK, etc.)

  • Is there existing instrumentation?

No integration yet: Set up Langfuse using a framework integration if available. Integrations capture more context automatically and require less code than manual instrumentation.

Integration exists: Audit against baseline requirements below.

2. Verify Baseline Requirements

Every trace should have these fundamentals:

Requirement Check Why

Model name Is the LLM model captured? Enables model comparison and filtering

Token usage Are input/output tokens tracked? Enables automatic cost calculation

Good trace names Are names descriptive? (chat-response, not trace-1) Makes traces findable and filterable

Span hierarchy Are multi-step operations nested properly? Shows which step is slow or failing

Correct observation types Are generations marked as generations? Enables model-specific analytics

Sensitive data masked Is PII/confidential data excluded or masked? Prevents data leakage

Trace input/output Does the trace capture the full data being processed as input, and the result as output? Enables debugging and understanding what was processed

Framework integrations (OpenAI, LangChain, etc.) handle model name, tokens, and observation types automatically. Prefer integrations over manual instrumentation.

Docs: https://langfuse.com/docs/tracing

3. Explore Traces First

Once baseline instrumentation is working, encourage the user to explore their traces in the Langfuse UI before adding more context:

"Your traces are now appearing in Langfuse. Take a look at a few of them—see what data is being captured, what's useful, and what's missing. This will help us decide what additional context to add."

This helps the user:

  • Understand what they're already getting

  • Form opinions about what's missing

  • Ask better questions about what they need

4. Discover Additional Context Needs

Determine what additional instrumentation would be valuable. Infer from code when possible, only ask when unclear.

Infer from code:

If you see in code... Infer Suggest

Conversation history, chat endpoints, message arrays Multi-turn app session_id

User authentication, user_id variables User-aware app user_id on traces

Multiple distinct endpoints/features Multi-feature app feature tag

Customer/tenant identifiers Multi-tenant app customer_id or tier tag

Feedback collection, ratings Has user feedback Capture as scores

Only ask when not obvious from code:

  • "How do you know when a response is good vs bad?" → Determines scoring approach

  • "What would you want to filter by in a dashboard?" → Surfaces non-obvious tags

  • "Are there different user segments you'd want to compare?" → Customer tiers, plans, etc.

Additions and their value:

Addition Why Docs

session_id Groups conversations together https://langfuse.com/docs/tracing-features/sessions

user_id Enables user filtering and cost attribution https://langfuse.com/docs/tracing-features/users

User feedback score Enables quality filtering and trends https://langfuse.com/docs/scores/overview

feature tag Per-feature analytics https://langfuse.com/docs/tracing-features/tags

customer_tier tag Cost/quality breakdown by segment https://langfuse.com/docs/tracing-features/tags

These are NOT baseline requirements—only add what's relevant based on inference or user input.

5. Guide to UI

After adding context, point users to relevant UI features:

  • Traces view: See individual requests

  • Sessions view: See grouped conversations (if session_id added)

  • Dashboard: Build filtered views using tags

  • Scores: Filter by quality metrics

Framework Integrations

Prefer these over manual instrumentation:

Framework Integration Docs

OpenAI SDK Drop-in replacement https://langfuse.com/docs/integrations/openai

LangChain Callback handler https://langfuse.com/docs/integrations/langchain

LlamaIndex Callback handler https://langfuse.com/docs/integrations/llama-index

Vercel AI SDK OpenTelemetry exporter https://langfuse.com/docs/integrations/vercel-ai-sdk

LiteLLM Callback or proxy https://langfuse.com/docs/integrations/litellm

Full list: https://langfuse.com/docs/integrations

Always Explain Why

When suggesting additions, explain the user benefit:

"I recommend adding session_id to your traces.

Why: This groups messages from the same conversation together.
You'll be able to see full conversation flows in the Sessions view,
making it much easier to debug multi-turn interactions.

Learn more: https://langfuse.com/docs/tracing-features/sessions"

Common Mistakes

Mistake Problem Fix

No flush() in scripts Traces never sent Call langfuse.flush() before exit

Flat traces Can't see which step failed Use nested spans for distinct steps

Generic trace names Hard to filter Use descriptive names: chat-response, doc-summary

Logging sensitive data Data leakage risk Mask PII before tracing

Manual instrumentation when integration exists More code, less context Use framework integration

Langfuse import before env vars loaded Langfuse initializes with missing/wrong credentials Import Langfuse AFTER loading environment variables (e.g., after load_dotenv())

Wrong import order with OpenAI Langfuse can't patch the OpenAI client Import Langfuse and call its setup BEFORE importing OpenAI client

Weekly Installs213Repositorylangfuse/skillsGitHub Stars28First SeenJan 23, 2026Security AuditsGen Agent Trust HubFailSocketPassSnykPassInstalled oncodex185opencode185gemini-cli175github-copilot167claude-code136kimi-cli135

用户评价 (0)

发表评价

效果
易用性
文档
兼容性

暂无评价

统计数据

安装量19.6K
评分4.6 / 5.0
版本
更新日期2026年10月23日
对比案例1 组

用户评分

4.6(24)
5
21%
4
50%
3
25%
2
4%
1
0%

为此 Skill 评分

0.0

兼容平台

🔧Claude Code
🔧OpenClaw
🔧OpenCode
🔧Codex
🔧Gemini CLI
🔧GitHub Copilot
🔧Amp
🔧Kimi CLI

时间线

创建2026年3月17日
最后更新2026年10月23日
🎁 Agent 知识卡片
调研问卷