You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components-mdx/integration-learn-more.mdx
+31-25Lines changed: 31 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,27 +18,31 @@ You can use this integration together with the Langfuse [Python SDK](/docs/obser
18
18
The [`@observe()` decorator](/docs/observability/sdk/python/instrumentation#custom-instrumentation) provides a convenient way to automatically wrap your instrumented code and add additional attributes to the trace.
19
19
20
20
```python
21
-
from langfuse import observe, get_client
21
+
from langfuse import observe, propagate_attributes, get_client
22
22
23
23
langfuse = get_client()
24
-
24
+
25
25
@observe()
26
-
defmy_instrumented_function(input):
27
-
28
-
# Run your application here
29
-
output = my_llm_call(input)
30
-
31
-
langfuse.update_current_trace(
32
-
input=input,
33
-
output=output,
26
+
defmy_llm_pipeline(input):
27
+
# Add additional attributes (user_id, session_id, metadata, version, tags) to all spans created within this execution scope
Learn more about using the Decorator in the [Python SDK](/docs/observability/sdk/python/instrumentation#custom-instrumentation) docs.
@@ -49,24 +53,26 @@ Learn more about using the Decorator in the [Python SDK](/docs/observability/sdk
49
53
The [Context Manager](/docs/observability/sdk/python/instrumentation#custom-instrumentation) allows you to wrap your instrumented code using context managers (with `with` statements), which allows you to add additional attributes to the trace.
50
54
51
55
```python
52
-
from langfuse import get_client
56
+
from langfuse import get_client, propagate_attributes
53
57
54
58
langfuse = get_client()
55
59
56
-
with langfuse.start_as_current_span(name="my-trace") as span:
57
-
58
-
# Run your application here
59
-
output = my_llm_call(input)
60
-
61
-
# Pass additional attributes to the span
62
-
span.update_trace(
63
-
input=input,
64
-
output=output,
60
+
with langfuse.start_as_current_observation(as_type="span", name="my-trace") as span:
61
+
# Add additional attributes (user_id, session_id, metadata, version, tags) to all spans created within this execution scope
0 commit comments