Skip to content

docs: replace removed v2 langfuse_context with v3 get_client() in empty-trace FAQ#3094

Open
i-anubhav-anand wants to merge 1 commit into
langfuse:mainfrom
i-anubhav-anand:docs/fix-empty-trace-langfuse-context
Open

docs: replace removed v2 langfuse_context with v3 get_client() in empty-trace FAQ#3094
i-anubhav-anand wants to merge 1 commit into
langfuse:mainfrom
i-anubhav-anand:docs/fix-empty-trace-langfuse-context

Conversation

@i-anubhav-anand

@i-anubhav-anand i-anubhav-anand commented Jun 14, 2026

Copy link
Copy Markdown

What does this PR do?

The "Empty trace input and output" FAQ page mixes SDK versions. The first Python tab correctly uses the v3+ API:

from langfuse import get_client
langfuse = get_client()
langfuse.flush()

…but the @observe() decorator example just below it still uses the removed v2 API:

from langfuse import observe, langfuse_context
...
langfuse_context.flush()

langfuse_context is not importable from the langfuse package in v3/v4 (in v2 it lived under langfuse.decorators, never top-level), so copying this snippet raises ImportError. This PR aligns it with the v3+ pattern already used elsewhere on the same page:

from langfuse import observe, get_client
...
get_client().flush()

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

Checklist

  • Self-reviewed; single hand-authored MDX file; consistent with the v3 usage already in this file.

Greptile Summary

This PR fixes a single MDX documentation file where the @observe() decorator example incorrectly imported and called the removed v2 langfuse_context API instead of the v3+ get_client() pattern already used everywhere else on the same page.

  • Replaces from langfuse import observe, langfuse_contextfrom langfuse import observe, get_client to match the v3 import convention used in the surrounding snippets.
  • Replaces langfuse_context.flush()get_client().flush(), making the flush call consistent with the standalone (non-decorator) Python example directly above it.

Confidence Score: 5/5

Single-line docs-only change that removes a broken import/call and replaces it with the correct v3 pattern already used on the same page.

The change is minimal and targeted — two lines in one MDX file. The replacement get_client().flush() is the canonical v3 flush pattern and is used correctly outside any function (after main() returns), matching the singleton-client pattern already demonstrated in the snippet directly above it. No logic, config, or runtime code is touched.

No files require special attention.

Sequence Diagram

sequenceDiagram
    participant User as User Script
    participant Observe as @observe() decorator
    participant Client as get_client()
    participant Queue as Background Queue
    participant API as Langfuse API

    User->>Observe: main()
    Observe->>Queue: enqueue span/trace data
    Observe-->>User: return
    User->>Client: get_client().flush()
    Client->>Queue: drain all pending events
    Queue->>API: POST /ingestion (batch)
    API-->>Queue: 200 OK
    Client-->>User: flush complete
Loading

Reviews (1): Last reviewed commit: "docs: replace removed v2 langfuse_contex..." | Re-trigger Greptile

@claude claude Bot 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.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@vercel

vercel Bot commented Jun 14, 2026

Copy link
Copy Markdown

@i-anubhav-anand is attempting to deploy a commit to the langfuse Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working docs labels Jun 14, 2026
@CLAassistant

CLAassistant commented Jun 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Labels

bug Something isn't working docs size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants