Hi Phoenix team - if I know the span_id for a particular trace, is there any way to delete it from the database? Context: this is a legal requirement for using Phoenix in production where the users should be able to request to delete their data anytime. Thanks!
Phoenix does not currently provide a dedicated REST API to delete individual spans by span_id. However, you can manually connect to the database (SQLite or PostgreSQL) and issue SQL queries to delete spans older than a certain date or by specific IDs. For traces, there is a delete_traces function in the backend that deletes traces by their IDs, but there is no equivalent public function or API for deleting individual spans by span_id (Slack discussion, phoenix/server/api/utils.py).If you need to automate span deletion, you would have to write a custom script that connects to your database and deletes the span with the given span_id. There is no built-in UI or API endpoint for this use case as of now. Would you like more detail on how to write such a script?Sources:
- Slack conversation on deleting traces and spans
- phoenix/server/api/utils.py
💡 Hint: Mention RunLLM in the thread for followups.
Could you please share more details on the SQL queries to delete the record by using span_id?
Like the table, and the related schema etc. Thanks!
If you tell me the right answer to this question, I'll make sure I don't make the same mistake twice!
Feedback
Type the right answer here...
↵ Please 'enter' to submit
Thanks for the feedback! I have learned the following:
Question: Hi Phoenix team - if I know the span_id for a particular trace, is there any way to delete it from the database? Context: this is a legal requirement for using Phoenix in production where the users should be able to request to delete their data anytime. Could you please share more details on the SQL queries to delete the record by using span_id? Like the table, and the related schema etc. Thanks!
Answer: Phoenix does not currently provide a dedicated REST API to delete individual spans by span_id. However, you can manually connect to the database (SQLite or PostgreSQL) and issue SQL queries to delete spans older than a certain date or by specific IDs. For traces, there is a delete_traces function in the backend that deletes traces by their IDs, but there is no equivalent public function or API for deleting individual spans by span_id. If you need to automate span deletion, you would have to write a custom script that connects to your database and deletes the span with the given span_id. There is no built-in UI or API endpoint for this use case as of now.
Hey Grace C., definitely hear you on this. I'd strongly recommend not to manually delete spans from the database since there are complex relationships between the spans tables and other tables (traces, sessions, etc.). If you file us an enhancement request on GitHub, we'll add a POST route to delete spans by ID.
This one: https://github.com/Arize-ai/phoenix
Request added - thanks Xander S. Dustin N.! 🙏 https://github.com/Arize-ai/phoenix/issues/7937
