-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
It would be great if we could customize span_data for any given span.
The metadata field only works for the top level trace, but child spans like response_span
do not have any existing metadata (nor the ability to add such metadata) such as current_turn, agent_name etc that is useful for querying data.
I think a simple solution for now could be to use the AgentHooks to manipulate the current_span and add any metadata you like.
def on_llm_start(..., agent: str, ...):
current_span = get_current_span() # response span
current_span.span_data["custom_metadata"] = agent.name
To do this, all spans would need to start before the _start hooks are called and finish after the _end hooks are called.
This is not standardized currently. Agent span follows this pattern, while response span starts after the on_llm_start
hook and ends before the on_llm_end
hook, making it difficult to manipulate the span data.