Skip to content

Add model-agnostic Langfuse observability#2937

Open
ganievs wants to merge 10 commits into
HKUDS:mainfrom
ganievs:langfuse-traces
Open

Add model-agnostic Langfuse observability#2937
ganievs wants to merge 10 commits into
HKUDS:mainfrom
ganievs:langfuse-traces

Conversation

@ganievs
Copy link
Copy Markdown

@ganievs ganievs commented Apr 14, 2026

Description

Related Issues

Changes Made

New file: lightrag/tracing.py — thin utility layer

  • is_tracing_enabled() - checks env vars + package availability
  • create_traced_llm_wrapper() - wraps any LLM function as a Langfuse generation using observe() functional form
  • report_token_usage() - forwards token counts to current Langfuse generation
  • propagate_trace_attributes() - sets user_id, session_id, tags on traces
  • flush() / shutdown() - lifecycle management

lightrag/lightrag.py

lightrag/utils.py

  • embedding + cache tracing

lightrag/llm/openai.py

  • token usage reporting
  • Removed old langfuse.openai drop-in import (was creating independent traces)

Dockerfile — installs observability extra by default
pyproject.toml — bumped langfuse>=4.0.6

Checklist

  • Changes tested locally
  • Code reviewed
  • Documentation updated (if necessary)
  • Unit tests added (if applicable)

Additional Notes

[Add any additional notes or context for the reviewer(s).]

@ganievs
Copy link
Copy Markdown
Author

ganievs commented Apr 14, 2026

I've checked via OpenAI and Bedrock both works well.

CleanShot 2026-04-14 at 18 46 02@2x

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d98fe4b606

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lightrag/lightrag.py Outdated
@danielaskdd danielaskdd added the enhancement New feature or request label Apr 18, 2026
@ganievs
Copy link
Copy Markdown
Author

ganievs commented May 21, 2026

Hi @danielaskdd - friendly ping on this one.
It's been about a month since the enhancement label went on and I wanted to check in on the merge timeline.
A few teams (including ours) are actively looking to roll out model-agnostic Langfuse tracing across LightRAG deployments - right now we're running off a fork, and we'd much rather consume this from upstream so we stay aligned with future changes.

Is there anything blocking on your side, or a rough timeframe you can share? Thanks!

ganievs added 2 commits May 21, 2026 15:22
Signed-off-by: Shamil Ganiev <ganiev@pm.me>
…ndent traces that bypass the trace hierarchy managed by lightrag.tracing

Signed-off-by: Shamil Ganiev <ganiev@pm.me>
ganievs added 6 commits May 21, 2026 16:13
Signed-off-by: Shamil Ganiev <ganiev@pm.me>
Signed-off-by: Shamil Ganiev <ganiev@pm.me>
Signed-off-by: Shamil Ganiev <ganiev@pm.me>
Signed-off-by: Shamil Ganiev <ganiev@pm.me>
Signed-off-by: Shamil Ganiev <ganiev@pm.me>
…hutdown_tracing to the server scope

Signed-off-by: Shamil Ganiev <ganiev@pm.me>
@ganievs ganievs force-pushed the langfuse-traces branch from cc0a3fa to 5fb1c00 Compare May 21, 2026 13:32
Signed-off-by: Shamil Ganiev <ganiev@pm.me>
@ganievs
Copy link
Copy Markdown
Author

ganievs commented Jun 5, 2026

Up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants