Skip to content

feat: add set_langfuse_context helpers for trace metadata - #3893

Open
chakshu-dhannawat wants to merge 2 commits into
deepset-ai:mainfrom
chakshu-dhannawat:feat/langfuse-context-helpers
Open

chakshu-dhannawat wants to merge 2 commits into
deepset-ai:mainfrom
chakshu-dhannawat:feat/langfuse-context-helpers

Conversation

@chakshu-dhannawat

Copy link
Copy Markdown
Contributor

Adds convenience helpers to set/reset Langfuse trace-level context without manually touching the internal context variable.

New exports in haystack_integrations.tracing.langfuse:

  • set_langfuse_context(trace_id, user_id, session_id, tags, version)
  • reset_langfuse_context(token)
  • LangfuseContextToken

These wrap the existing tracing_context_var plumbing that LangfuseTracer already reads when creating a root trace. They make it easier to attach user_id, session_id, tags, version, and trace_id to the next pipeline run, as discussed in #1279 and #1264.

Closes #1279
Relates to #1264

How did you test it?

  • Added unit tests covering full/partial updates, token-based reset, and clearing.
  • Ran hatch run test:unit and hatch run test:types for the langfuse integration.

Checklist

Adds convenience functions to set/reset Langfuse trace-level context
(user_id, session_id, tags, version, trace_id) without manually touching
the context variable. This makes the existing tracing_context_var behavior
discoverable and easier to use.

Closes deepset-ai#1279
@chakshu-dhannawat
chakshu-dhannawat requested a review from a team as a code owner September 2, 2026 03:05
@chakshu-dhannawat
chakshu-dhannawat requested review from julian-risch and removed request for a team September 2, 2026 03:05
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Hi @chakshu-dhannawat, thanks for your interest in contributing to Haystack! 🙏

⚠️ You currently have 3 open pull requests in this repository (#3846, #3525 and this one). Our review capacity is limited, so please hold off opening more PRs until we've had a chance to review your first 2 open PRs. This helps us give each contribution the attention it deserves. Thank you!

This is an automated message to help us keep the review queue healthy.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Heads-up for maintainers

This PR is from a fork and touches integrations whose integration tests require API keys.
Those tests are skipped in CI because fork PRs don't have access to repo secrets for security reasons.

Affected integrations:

  • langfuse

Please run the integration tests locally (hatch run test:integration inside each folder) before approving.

@github-actions github-actions Bot added the type:documentation Improvements or additions to documentation label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Coverage report (langfuse)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/langfuse/src/haystack_integrations/tracing/langfuse
  tracer.py
Project Total  

This report was generated by python-coverage-comment-action

…et_langfuse_context

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chakshu-dhannawat

Copy link
Copy Markdown
Contributor Author

Hi @julian-risch, gentle ping for a review when you have a moment. Thanks.

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

integration:langfuse type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Langfuse tags and user_id on Haystack

2 participants