Skip to content

Commit 441d3f9

Browse files
Align adapter docs with propagate-on-every behavior
Three stale-doc residues from when the adapter consumed trace_info on the first observation only. The current behavior — propagate on every observation under each trace_id to avoid v4's last-attribute- wins display logic clobbering the trace name — got caught by the integration-test run and the cache+propagation refactored, but the module header comments and one example-doc paragraph still described the original "first observation only" path. Comment / doc text updated; no code change. Addresses CoPilot PR review feedback on #82.
1 parent 812b27e commit 441d3f9

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

docs/examples/10-langfuse-observability.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ The adapter bridges `langfuse>=4.6,<5`'s unified `start_observation`
145145
API onto OA's four-method `LangfuseClient` Protocol. v4 has no
146146
explicit trace creation (traces are auto-created from observations);
147147
the adapter caches trace info from `.trace()` and applies it via
148-
`propagate_attributes` around the first observation, so trace name
149-
+ metadata land on the trace as Langfuse renders it.
148+
`propagate_attributes` around EVERY observation under that trace_id.
149+
Propagating on every observation keeps v4's last-attribute-wins
150+
display logic from clobbering the trace's display name when later
151+
observations land without the attribute set.
150152

151153
Validated against `langfuse>=4.6,<5`. v2.x and v3.x are NOT
152154
supported — supply your own adapter against the same four-method

src/openarmature/observability/langfuse/adapter.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,26 @@
88
# - v4 has no explicit `client.trace(...)` — traces are auto-created
99
# when the first observation starts. We cache the trace name +
1010
# metadata on `.trace()` and apply them via `propagate_attributes`
11-
# around the first observation under that trace_id.
11+
# around EVERY observation under that trace_id. Propagating on
12+
# every observation (not just the first) keeps v4's
13+
# last-attribute-wins display logic from clobbering the trace's
14+
# display name when later observations land without the attribute
15+
# set.
1216
# - v4 unifies span and generation under `start_observation(as_type=)`.
1317
# The adapter routes `.span()` to `as_type="span"` and
1418
# `.generation()` to `as_type="generation"`.
1519
# - v4's `propagate_attributes(metadata=...)` requires Dict[str, str]
1620
# (not Dict[str, Any]). Non-string values are JSON-serialized at
1721
# the boundary.
1822
#
19-
# `update_trace` is best-effort. v4 doesn't expose a clean
20-
# post-creation trace-update SDK method — we can only mutate trace
21-
# fields via OTel attributes during observation creation. The current
22-
# OA LangfuseObserver doesn't actually invoke `update_trace` (caller-
23-
# supplied invocation-label lands in PR 4 via the
24-
# `propagate_attributes` path on first observation instead), so the
25-
# adapter no-ops it and updates the cached pending info in case some
26-
# future caller needs it before the trace materializes.
23+
# `update_trace` merges into the persistent trace_info cache so
24+
# subsequent observations under the trace_id pick up the new values
25+
# via `propagate_attributes`. Existing observations are NOT
26+
# retroactively updated. The current OA LangfuseObserver doesn't
27+
# actually invoke `update_trace` today — caller-supplied
28+
# invocation-label lands in PR 4 via the trace_info cache before the
29+
# first observation creates the trace — but the merge-then-propagate
30+
# path is wired for forward compat.
2731

2832
"""LangfuseSDKAdapter: bridge langfuse>=4.6 onto the LangfuseClient Protocol."""
2933

0 commit comments

Comments
 (0)