Your 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 <https://github.com/Arize-ai/phoenix/blob/main/docs/tracing/how-to-tracing/customize-spans.md|customize spans docs> and <https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py|context manager source>.
Would you like more detail or a code example?
Sources:
- <https://github.com/Arize-ai/phoenix/blob/main/docs/tracing/how-to-tracing/customize-spans.md|customize spans docs>
- <https://github.com/Arize-ai/openinference/blob/main/python/openinference-instrumentation/src/openinference/instrumentation/context_attributes.py|context manager source>