Skip to content

feat(client): allow updating span/generation name#1255

Merged
hassiebp merged 1 commit intomainfrom
hassieb/lfe-5611-allow-renaming-span-name
Jul 14, 2025
Merged

feat(client): allow updating span/generation name#1255
hassiebp merged 1 commit intomainfrom
hassieb/lfe-5611-allow-renaming-span-name

Conversation

@hassiebp
Copy link
Copy Markdown
Contributor

@hassiebp hassiebp commented Jul 14, 2025

Disclaimer: Experimental PR review

Greptile Summary

This PR introduces the ability to update span and generation names after their initial creation in the Langfuse Python SDK. This is a significant usability enhancement that allows developers to dynamically rename spans during execution when the appropriate name might only be known after some processing or based on runtime conditions.

The changes include:

  1. Adding a 'name' parameter to the update() method for both LangfuseSpan and LangfuseGeneration classes
  2. Implementing name updates through OpenTelemetry's update_name() method
  3. Adding support in both direct span updates (span.update()) and context-based updates (update_current_span)
  4. Comprehensive test coverage for all new functionality

The implementation maintains consistency with existing SDK patterns and leverages OpenTelemetry's standard conventions.

Confidence score: 5/5

  1. This PR is extremely safe to merge as it adds new functionality without modifying existing behavior
  2. The high score is due to comprehensive test coverage, clean implementation following existing patterns, and use of established OpenTelemetry conventions
  3. While all changes look solid, pay extra attention to langfuse/_client/span.py as it contains the core implementation of the new functionality

3 files reviewed, no comments
Edit PR Review Bot Settings | Greptile


Important

Add functionality to update span and generation names in Langfuse client, with tests verifying the updates.

  • Behavior:
    • Add name parameter to update_current_generation() and update_current_span() in client.py to allow updating the name of the current generation and span.
    • Update LangfuseSpan.update() and LangfuseGeneration.update() in span.py to support name updates.
    • If name is provided, the OpenTelemetry span name is updated using update_name().
  • Tests:
    • Add test_update_current_span_name() and test_update_current_generation_name() in test_otel.py to verify span and generation name updates.
    • Ensure no spans exist with the original name after an update.
    • Add test_span_name_update() and test_generation_name_update() to verify direct updates via update() method.

This description was created by Ellipsis for e8a0839. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Copy Markdown
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.

Reviewing changes made in this pull request

Comment thread langfuse/_client/client.py
@hassiebp hassiebp merged commit 81bd053 into main Jul 14, 2025
10 checks passed
@hassiebp hassiebp deleted the hassieb/lfe-5611-allow-renaming-span-name branch July 14, 2025 14:04
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