hi everyone. i'm converting a langsmith-instrumented large project to arize. one convenience that langsmith has is that it displays what otel would call span attributes that are dictionaries in a convenient way in the dashboard. is there any equivalent way to do this in arize? or is json serialized strings the best we've got?
Phoenix supports displaying span attributes that are dictionaries in a structured, nested JSON format in the dashboard, not just as raw JSON strings. The attributes are automatically un-flattened and presented as nested objects, making them more readable and convenient to explore in the UI, similar to LangSmith's approach. This is achieved by splitting attribute keys on the . separator and reconstructing them into nested dictionaries for display purposes, as described in src/phoenix/trace/attributes.py and implemented in the UI per feat(trace): nested attributes.For attributes that are JSON-serialized strings (such as certain metadata fields), Phoenix will attempt to parse and display them as structured JSON when possible, falling back to string display only if parsing fails. This behavior is documented in src/phoenix/trace/attributes.py and feat(gql): span attributes as json string.Would you like more detail or code examples on how to ensure your attributes are displayed this way?Sources:
- src/phoenix/trace/attributes.py
- feat(trace): nested attributes
- feat(gql): span attributes as json string
馃挕聽Hint: Mention RunLLM in the thread for followups.
Yes, you can use span.set_attribute to create nested attributes by using dot notation in the key. Phoenix will display these as structured/nested objects in the UI. For example: LBKSspan.set_attribute("metadata.source", "search_engine") span.set_attribute("metadata.score", 0.98) span.set_attribute("metadata.details.author", "Alice") span.set_attribute("metadata.details.length", 1234)LBKSThis will appear in the Phoenix UI as a nested dictionary under the metadata key, with source, score, and a nested details object, as described in src/phoenix/trace/attributes.py.Would you like a more complete example or further explanation?Sources:
- https://github.com/Arize-ai/phoenix/issues/7687
- https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md
馃挕聽Hint: Mention RunLLM in the thread for followups.
Yes, Phoenix provides utility methods to flatten a nested Python dictionary into dot notation key-value pairs suitable for span.set_attribute. Use the flatten function from src/phoenix/trace/attributes.py: LBKSfrom phoenix.trace.attributes import flattenLBKSnested_dict = { "metadata": { "source": "search_engine", "details": {"author": "Alice", "length": 1234} } } for key, value in flatten(nested_dict): span.set_attribute(key, value)LBKSWould you like more detail on how this function works or how to handle lists?Sources:
- src/phoenix/trace/attributes.py
馃挕聽Hint: Mention RunLLM in the thread for followups.
Yes, you need to install the arize-phoenix package to access phoenix.trace.attributes.flatten. Install it with: LBKSpip install arize-phoenixLBKSThis will provide the necessary modules, including the flatten utility. Would you like more details on installation or usage?Sources:
- src/phoenix/trace/attributes.py
- Arize Phoenix Python Reference
馃挕聽Hint: Mention RunLLM in the thread for followups.
