Skip to content

Add model-agnostic Langfuse observability - #2937

Draft
ganievs wants to merge 9 commits into
HKUDS:mainfrom
ganievs:langfuse-traces
Draft

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

Conversation

@ganievs

@ganievs ganievs commented Apr 14, 2026 •

Copy link
Copy Markdown

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

ganievs commented Apr 14, 2026

Copy link
Copy Markdown
Author

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

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

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

Copy link
Copy Markdown
Contributor

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 Resolved
@danielaskdd danielaskdd added the enhancement New feature or request label Apr 18, 2026
@ganievs

ganievs commented May 21, 2026

Copy link
Copy Markdown
Author

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

ganievs commented Jun 5, 2026

Copy link
Copy Markdown
Author

Up

ganievs added 9 commits July 6, 2026 16:05
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>
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 6372fa6 to c3d83af Compare July 6, 2026 14:28
@danielaskdd
danielaskdd marked this pull request as draft August 16, 2026 04:31

@dianatofficial dianatofficial left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great catch on this edge case. The fallback logic looks robust.

This branch has not been deployed

No deployments
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.

3 participants