Why is code not adding metadata to my span?
@tracer.tool()
def translate(a,b, c):
my_uuid = uuid.uuid4()
metadata = {"conversation_id": my_uuid}
with using_metadata(metadata):
#my logic goes here
returnYour code is not adding metadata to your span because the using_metadata context manager only affects spans created within its block. In your example, the span for the translate tool is created by the @tracer.tool() decorator before entering the with using_metadata(metadata): block, so the metadata is not attached to the tool span. To ensure the metadata is included, wrap the entire function body (including the tool logic) with using_metadata, or use @using_metadata(metadata) as a decorator above the function definition. See customize spans docs and context manager source.Would you like more detail or a code example?Sources:
- customize spans docs
- context manager source
๐กย Hint: Mention RunLLM in the thread for followups.
