Llama Index span custom attributes 🧵
To add custom attributes to spans in LlamaIndex, you can use the LlamaIndexInstrumentor which allows you to instrument your application and add custom attributes to spans. According to the LlamaIndex documentation, you can initialize the LlamaIndexInstrumentor before your application code to automatically capture traces and send them to Phoenix. You can then use the OpenTelemetry API to set custom attributes on spans.If you need more detailed guidance on how to implement this, please let me know.Sources:
- LlamaIndex documentation
💡 Hint: Mention RunLLM in the thread for followups.
Hi guys, I'm trying to add custom attributes to the spans automatically created by Llama Index, which will help us better query them in Phoenix. Llama Index provides the instrument_tags method (in llama-index-core/llama_index/core/instrumentation/dispatcher.py:33) that allows binding custom tags:
with instrument_tags({"my_custom_attribute": "anything_i_want"}):
resp = llm.complete("Hello World!")These tags are passed to _SpanHandler.new_span in openinference/instrumentation/llama_index/_handler.py:769, but currently, the handler doesn't utilize these tags. Should we update openinference/instrumentation/llama_index to handle these tags explicitly, or is there another recommended approach to attach custom attributes to internal Llama Index spans? Thanks for your support!
