docs: fix invalid langfuse.trace() context manager in OTel setup guide#3092
Open
i-anubhav-anand wants to merge 1 commit into
Open
docs: fix invalid langfuse.trace() context manager in OTel setup guide#3092i-anubhav-anand wants to merge 1 commit into
langfuse.trace() context manager in OTel setup guide#3092i-anubhav-anand wants to merge 1 commit into
Conversation
The Python tab in the existing-OTel-setup guide showed `with langfuse.trace(...) as trace:`, which is not a valid Python SDK API (`langfuse.trace()` does not exist in v3/v4 and was never a context manager), so the snippet raises AttributeError if copied. Replace it with the canonical `propagate_attributes()` context manager, which mirrors the JS/TS tab's `propagateAttributes` and matches the v3-to-v4 migration guide (`name` -> `trace_name`).
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The Python tab in the "Set trace-level data explicitly" section of the Using Langfuse with an existing OpenTelemetry setup FAQ page showed:
This is not valid:
langfuse.trace()does not exist in the v3/v4 Python SDK and was never a context manager, so anyone copying the snippet hits anAttributeError. The rest of the page already uses the v4 API (the JS/TS tab usespropagateAttributes).This PR replaces it with the canonical v4
propagate_attributes()context manager, which is the documented replacement forupdate_current_trace()per the v3-to-v4 migration guide (name→trace_name), and mirrors the JS/TS tab on the same page:Type of change
Checklist
Greptile Summary
Fixes a broken Python code snippet in the "Set trace-level data explicitly" section of the existing-OTel-setup FAQ by replacing the non-existent
langfuse.trace()context manager with the correct v4propagate_attributes()API.langfuse.trace(name=...)— which does not exist in the v3/v4 SDK — withfrom langfuse import propagate_attributesfollowed bypropagate_attributes(trace_name=..., user_id=..., session_id=...), matching the documented v4 migration path.propagateAttributes.Confidence Score: 5/5
Single-file documentation fix replacing a non-functional Python snippet with the correct v4 API call — no runtime code is touched and the change is straightforwardly correct.
The replacement uses the right function name (propagate_attributes), the right parameter (trace_name instead of name), includes the necessary import at the top of the snippet, and matches both the JS/TS counterpart on the same page and the official v3→v4 migration guide. No logic, no runtime behavior, and no other files are affected.
No files require special attention.
Sequence Diagram
sequenceDiagram participant User as Developer participant SDK as Langfuse v4 SDK participant OTel as OpenTelemetry User->>SDK: propagate_attributes(trace_name, user_id, session_id) SDK->>OTel: Set trace-level attributes on active span context OTel-->>SDK: Context propagated SDK-->>User: Context manager yields User->>OTel: Instrumented code runs within context OTel-->>SDK: Spans captured with propagated attributes SDK-->>User: Trace visible in Langfuse with correct metadataReviews (1): Last reviewed commit: "docs: fix invalid langfuse.trace() conte..." | Re-trigger Greptile