Skip to content

Add model-agnostic Langfuse observability#2937

Open
ganievs wants to merge 9 commits intoHKUDS:mainfrom
ganievs:langfuse-traces
Open

Add model-agnostic Langfuse observability#2937
ganievs wants to merge 9 commits intoHKUDS: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 added 7 commits April 8, 2026 20:03
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>
@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
ganievs added 2 commits April 15, 2026 13:31
Signed-off-by: Shamil Ganiev <ganiev@pm.me>
…hutdown_tracing to the server scope

Signed-off-by: Shamil Ganiev <ganiev@pm.me>
@danielaskdd danielaskdd added the enhancement New feature or request label Apr 18, 2026
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