Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks including CrewAI, Agno, OpenAI Agents SDK, Langchain, Autogen, AG2, and CamelAI
Python agentagentopsagents-sdkaianthropicautogencost-estimationcrewaievalsevaluation-metricsgroqlangchainllmmistralollamaopenaiopenai-agents
Task: Implement Trace Endpoints for v4 API
Description
Create endpoints for querying trace data from Clickhouse. These endpoints will replace the existing v2 endpoints that query trace data from Supabase.
Requirements
- Implement endpoints for querying trace data
- Ensure compatibility with the existing v2 endpoints
- Optimize queries for performance
- Implement filtering, sorting, and pagination
- Handle error cases
Endpoints to Implement
GET /v4/traces: Get a list of tracesGET /v4/traces/{trace_id}: Get a specific trace by IDGET /v4/traces/{trace_id}/spans: Get spans for a specific traceGET /v4/traces/search: Search for traces based on criteria
Implementation Details
- Create a new file at
agentops/api/routes/v4/traces.py - Use the Clickhouse client to query trace data
- Implement filtering, sorting, and pagination
- Handle error cases
- Ensure compatibility with the existing v2 endpoints
Query Parameters
project_id: Filter by project IDstart_time: Filter by start timeend_time: Filter by end timeservice_name: Filter by service namespan_name: Filter by span namestatus_code: Filter by status codelimit: Limit the number of resultsoffset: Offset for pagination
Response Format
- Return JSON responses with trace data
- Include metadata for pagination
- Include links to related resources
Computed Fields Migration
- Identify computed fields in v2 endpoints (e.g., LLM calls, tool calls)
- Implement equivalent queries in Clickhouse
- Use span attributes and events to extract the required data
- Ensure backward compatibility with existing clients
Testing
- Create unit tests for the endpoints
- Test with real data in Clickhouse
- Test performance with large datasets
- Test error handling
Dependencies
- Clickhouse client implementation
- Authentication middleware
Estimated Time
8-10 hours