docs: document propagate_attributes scope, trace.list lightweight views, and ingestion latency#1764
Draft
jannikmaierhoefer wants to merge 1 commit into
Draft
docs: document propagate_attributes scope, trace.list lightweight views, and ingestion latency#1764jannikmaierhoefer wants to merge 1 commit into
jannikmaierhoefer wants to merge 1 commit into
Conversation
…t views, and ingestion latency Docstring-only changes, no behavior changes: - propagate_attributes: document exactly which spans receive the attributes (currently active span at context entry + every span started while the context is active), where they land in exported spans (user.id/session.id OTel attributes per span; trace-level fields after ingestion; Observation API objects expose no session_id/user_id), and the detached-root ordering pitfall with correct alternatives. - api.trace.list/get: note that list returns lightweight TraceWithDetails views (observations/scores are ID strings) and that get may 404 with langfuse.api.NotFoundError until async ingestion completes; recommend bounded retries. Note: these files are Fern-generated, so this text should also be upstreamed to the OpenAPI spec descriptions to survive regens. - flush()/create_score()/get_dataset_run(): clarify that flush guarantees delivery, not read visibility (typically 15-30s, no SLA). - Fix pre-existing docstring bug: examples called langfuse.propagate_attributes(...), but the client has no such method — use the module-level function; fix two :meth: cross-references to :func:. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 changed
Docstring-only changes closing three documentation gaps that agent-behavior testing showed cause real debugging sessions. No behavior changes. Companion docs PR: langfuse/langfuse-docs#3316.
1.
propagate_attributesscope semantics (langfuse/_client/propagation.py)start_observation(), which never become the active span) are not retroactively stamped.user.id/session.idOTel attributes on each covered exported span; after ingestion they surface as trace-level fields (api.trace.get(trace_id).session_id).ObservationAPI objects expose nosession_id/user_idfields, so asserting on fetched child observations always fails — a repeated source of confusion.span_processor.on_startand the 132 tests intests/unit/test_propagate_attributes.py(attributes do propagate to all child spans; the "root only" folk belief comes from the API surface, not the SDK).2.
trace.listreturns lightweight views (langfuse/api/trace/client.py)list(sync + async): documents thatobservations/scoresonTraceWithDetailsare ID strings, not full objects; trace-level aggregates are included; point totrace.get/observations.get_manyfor per-observation usage/cost.get(sync + async): documents full-detail return type and the 404-until-ingested behavior.3. Ingestion latency (
langfuse/_client/client.py)flush(): guarantees delivery, not read visibility; reads right after flush may raiselangfuse.api.NotFoundError(typically visible within ~15-30s, no fixed SLA) — retry with bounded backoff.create_score()andget_dataset_run(): same async-ingestion visibility notes.Drive-by fix (pre-existing docstring bug)
Docstring examples called
langfuse.propagate_attributes(...), but theLangfuseclient has no such method (hasattr(Langfuse, "propagate_attributes")isFalse) — following the documented examples raisedAttributeError. Examples now import and use the module-level function; two:meth:cross-references inclient.py/span.pycorrected to:func:.Reviewer notes
langfuse/api/trace/client.pyis Fern-generated — the added notes will be lost on the next API-spec regen unless the same text is upstreamed into the OpenAPI endpoint descriptions in langfuse/langfuse. Flagging rather than deciding: happy to drop that file from this PR if you prefer upstream-only.langfuse.api.NotFoundError; there is noLangfuseNotFoundErrorin this SDK.wait_for_trace()/retry-kwarg helper for now: trace presence ≠ trace completeness (observations arrive incrementally), so a naive helper would trade a loud 404 for silently incomplete usage/cost reads. The docs PR ships a bounded-backoff snippet instead.ruff check+ruff format --check,mypyon edited files,pytest tests/unit/test_propagate_attributes.py tests/unit/test_otel.py(197 passed, 2 skipped).🤖 Generated with Claude Code