Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do another update call when we're updating an ended trace in update_current_trace #1093

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions langfuse/decorators/langfuse_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,19 +792,21 @@ def update_current_trace(
if v is not None
}

trace_already_ended = trace_id not in _observation_params_context.get()
# metadata and tags are merged server side. Send separate update event to avoid merging them SDK side
server_merged_attributes = ["metadata", "tags"]
if any(attribute in params_to_update for attribute in server_merged_attributes):
if trace_already_ended or any(attribute in params_to_update for attribute in server_merged_attributes):
self.client_instance.trace(
id=trace_id,
**{
k: v
for k, v in params_to_update.items()
if k in server_merged_attributes
if k in server_merged_attributes or trace_already_ended
},
)

_observation_params_context.get()[trace_id].update(params_to_update)
if not trace_already_ended:
_observation_params_context.get()[trace_id].update(params_to_update)

def update_current_observation(
self,
Expand Down