Is there a way to auto delete spans after a certain time interval say 24 hours?
Phoenix does not currently support automatic deletion of spans after a certain time interval like 24 hours. However, you can manually connect to the database and issue queries to delete spans older than a certain date. For SQLite, there is no authentication required, and for PostgreSQL, you can log in as the root user to perform deletions (source).Would you like more details on how to manually delete spans from the database?Sources: - Slack conversation on TTL and manual deletion
π‘Β Hint: Mention RunLLM in the thread for followups.
are there queries already available to delete the spans
Yes, Phoenix provides a function to delete specific traces by their IDs using the delete_traces function. Here is an example: LBKSfrom phoenix.server.types import DbSessionFactoryLBKSasync def delete_traces(db: DbSessionFactory, *trace_ids: str) -> List[int]: if not trace_ids: return [] stmt = ( delete(models.Trace) .where(models.Trace.trace_id.in_(set(trace_ids))) .returning(models.Trace.id) ) async with db() as session: return list(await session.scalars(stmt))LBKSFor deleting projects, you can use the delete_projects function similarly (source).Would you like more details on how to use these functions?Sources:
- Slack conversation on deleting traces and spans
π‘Β Hint: Mention RunLLM in the thread for followups.
Oh yeah! I was just checking if there is an automated way. Is the other script given above correct? Then I can schedule a job with that.
hereβs the corresponding json payload for POST to http://0.0.0.0:6006/graphql
{
"query":"mutation RemoveProjectDataFormMutation(\n $input: ClearProjectInput!\n) {\n clearProject(input: $input) {\n __typename\n }\n}\n",
"variables":{
"input":{
"id":"UHJvamVjdDox",
"endTime":"2024-08-17T23:55:00.000Z"
}
}
}Hi! Just to follow up on this... The option to remove all traces up to some date is useful. Why not have deletion of single traces in a project in the UI? (e.g. in the same dialog that say offers "Cancle" and "Add to dataset", after selecting traces)
Hey Christopher, I think that makes a lot of sense. File us an issue and Iβll definitely tackle it soon.
