Skip to content

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Feb 9, 2026

Important

Pass release attribute to span clients in Langfuse, updating span creation and observation methods to include this attribute.

  • Behavior:
    • Pass release attribute to span clients in Langfuse class in client.py.
    • Update _create_observation_from_otel_span() and create_event() in client.py to include release.
    • Ensure release is set in LangfuseObservationWrapper and its subclasses in span.py.
  • Tests:
    • Add assertion for release in test_get_client_preserves_all_settings() in test_resource_manager.py.

This description was created by Ellipsis 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 release field 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 ensuring get_client() preserves the configured release.

The main remaining issue is an inconsistent instantiation path: Langfuse.update_current_generation() still constructs LangfuseGeneration without passing environment/release, so the current OTEL span won’t receive the intended release attribute in that flow. Aligning it with the other creation sites in client.py should make release propagation consistent across all span/generation APIs.

Confidence Score: 4/5

  • Mostly safe to merge after fixing one missed propagation path for release in update_current_generation().
  • Changes are localized to adding a new client setting and threading it through existing span/observation creation patterns, plus a test assertion. One definite inconsistency remains where a generation wrapper is created without passing environment/release, which undermines the stated goal in that code path.
  • langfuse/_client/client.py (update_current_generation instantiation)

Important Files Changed

Filename Overview
langfuse/_client/client.py Adds release handling (init/env propagation) and passes it to most span/generation creation sites; one existing code path (update_current_generation) still instantiates LangfuseGeneration without environment/release, so release won’t be applied there.
langfuse/_client/span.py Extends observation wrappers (Span/Generation/Event) to accept release, store it, and set OTEL attribute; propagates release to nested observations. Changes look consistent with existing environment propagation.
tests/test_resource_manager.py Adds assertion that retrieved client preserves release setting; 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 }
Loading

Context used:

  • Rule from dashboard - Move imports to the top of the module instead of placing them within functions or methods. (source)

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 9, 2026

Additional Comments (1)

langfuse/_client/client.py
Release not propagated

update_current_generation() creates LangfuseGeneration without passing environment/release (currently LangfuseGeneration(otel_span=current_otel_span, langfuse_client=self)), so the OTEL span won’t get the release attribute (and may also miss the explicit environment propagation you added elsewhere). This is inconsistent with other creation sites in this file that now pass both.

            generation = LangfuseGeneration(
                otel_span=current_otel_span,
                langfuse_client=self,
                environment=self._environment,
                release=self._release,
            )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant