fix(client): pass release variable to span clients #1518
+35
−0
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.
Important
Pass
releaseattribute to span clients in Langfuse, updating span creation and observation methods to include this attribute.releaseattribute to span clients inLangfuseclass inclient.py._create_observation_from_otel_span()andcreate_event()inclient.pyto includerelease.releaseis set inLangfuseObservationWrapperand its subclasses inspan.py.releaseintest_get_client_preserves_all_settings()intest_resource_manager.py.This description was created by
for f1b31fd. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Overview
Greptile Summary
This PR introduces a
releasefield on the Langfuse client and propagates it into span/observation wrappers so it’s set as an OpenTelemetry attribute and forwarded through nested observation creation. It also adds a regression assertion ensuringget_client()preserves the configuredrelease.The main remaining issue is an inconsistent instantiation path:
Langfuse.update_current_generation()still constructsLangfuseGenerationwithout passingenvironment/release, so the current OTEL span won’t receive the intendedreleaseattribute in that flow. Aligning it with the other creation sites inclient.pyshould make release propagation consistent across all span/generation APIs.Confidence Score: 4/5
releaseinupdate_current_generation().Important Files Changed
release, store it, and set OTEL attribute; propagates release to nested observations. Changes look consistent with existing environment propagation.releasesetting; straightforward and aligned with change.Sequence Diagram
sequenceDiagram autonumber participant U as User Code participant LF as Langfuse(Client) participant SC as Span Client participant OW as Observation Wrapper participant API as Langfuse API U->>LF: Langfuse(..., release=R) U->>LF: trace()/span()/event(...) LF->>SC: create_span(..., release=R) SC->>API: POST /spans { ..., release: R } LF->>OW: wrap observation (set release=R) OW->>API: update/create observation { ..., release: R } LF->>LF: _create_observation_from_otel_span(otelSpan) LF->>API: create observation { ..., release: R }Context used:
dashboard- Move imports to the top of the module instead of placing them within functions or methods. (source)