Skip to content

Commit 39194e6

Browse files
committed
push
1 parent b669e4d commit 39194e6

13 files changed

+612
-1259
lines changed

langfuse/_client/client.py

Lines changed: 11 additions & 317 deletions
Large diffs are not rendered by default.

langfuse/_client/propagation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ def propagate_attributes(
132132
langfuse = Langfuse()
133133
134134
# Set attributes early in the trace
135-
with langfuse.start_as_current_span(name="user_workflow") as span:
135+
with langfuse.start_as_current_observation(name="user_workflow") as span:
136136
with langfuse.propagate_attributes(
137137
user_id="user_123",
138138
session_id="session_abc",
139139
metadata={"experiment": "variant_a", "environment": "production"}
140140
):
141141
# All spans created here will have user_id, session_id, and metadata
142-
with langfuse.start_span(name="llm_call") as llm_span:
142+
with langfuse.start_observation(name="llm_call") as llm_span:
143143
# This span inherits: user_id, session_id, experiment, environment
144144
...
145145
@@ -151,15 +151,15 @@ def propagate_attributes(
151151
Late propagation (anti-pattern):
152152
153153
```python
154-
with langfuse.start_as_current_span(name="workflow") as span:
154+
with langfuse.start_as_current_observation(name="workflow") as span:
155155
# These spans WON'T have user_id
156-
early_span = langfuse.start_span(name="early_work")
156+
early_span = langfuse.start_observation(name="early_work")
157157
early_span.end()
158158
159159
# Set attributes in the middle
160160
with langfuse.propagate_attributes(user_id="user_123"):
161161
# Only spans created AFTER this point will have user_id
162-
late_span = langfuse.start_span(name="late_work")
162+
late_span = langfuse.start_observation(name="late_work")
163163
late_span.end()
164164
165165
# Result: Aggregations by user_id will miss "early_work" span
@@ -169,7 +169,7 @@ def propagate_attributes(
169169
170170
```python
171171
# Service A - originating service
172-
with langfuse.start_as_current_span(name="api_request"):
172+
with langfuse.start_as_current_observation(name="api_request"):
173173
with langfuse.propagate_attributes(
174174
user_id="user_123",
175175
session_id="session_abc",

0 commit comments

Comments
 (0)