Tracing API — Legacy Endpoints & Migration Guide
1. Legacy endpoints currently used by the web
All web calls go through /tracing/* (deprecated) or /tracing/spans/analytics (legacy, not formally deprecated).
| Endpoint |
Status |
Web callers |
POST /tracing/spans/query |
Deprecated |
fetchAllPreviewTraces(), fetchAllPreviewTracesWithMeta() in web/oss/src/services/tracing/api/index.ts and web/packages/agenta-entities/src/trace/api/api.ts |
POST /tracing/spans/analytics |
Legacy (not deprecated) |
fetchGenerationsDashboardData() in web/oss/src/services/tracing/api/index.ts |
GET /tracing/traces/{id} |
Deprecated |
fetchPreviewTrace() in both files above |
DELETE /tracing/traces/{id} |
Deprecated |
deletePreviewTrace() in both files above |
POST /tracing/sessions/query |
Deprecated |
fetchSessions() in both files above |
Deprecated endpoints that web does not call (safe to ignore for web migration):
POST /tracing/spans/ingest, POST /tracing/analytics/query, POST /tracing/traces/, PUT /tracing/traces/{id}, POST /tracing/users/query.
2. Migration considerations per endpoint
2.1 POST /tracing/spans/query → POST /spans/query
Request — what changes:
| Field |
Legacy |
New |
| Pagination |
windowing.limit, windowing.oldest/newest (implicit) |
windowing object — same struct, but cursor-only; oldest/newest as datetime |
| Filtering |
filter as freeform JSON blob |
filtering as structured {operator, conditions[]} |
| Focus |
focus: "trace" | "span" | "chat" in body |
focus removed — new endpoint always returns flat spans; query revisions with focus="trace" return 409 |
| Format |
format: "agenta" | "openai" | ... |
formatting object with {focus, format} |
| Saved query |
query_ref / query_variant_ref / query_revision_ref |
Same — unchanged |
Response — what changes:
|
Legacy OTelTracingResponse |
New SpansResponse |
| Shape |
{count, spans?, traces?} — one or the other depending on focus |
{count, spans} — always flat list, never traces |
| Trace-tree view |
Available via focus="trace" |
Not available — use GET /traces/ instead |
Impact: The web currently relies on focus="trace" to get the trace-tree shape. The new endpoint drops this entirely. The web would need to either: (a) keep using /tracing/spans/query until a proper trace-tree endpoint migration is scoped, or (b) switch to GET /traces/ for trace-tree views and POST /spans/query for flat span views separately.
2.2 POST /tracing/spans/analytics → POST /spans/analytics/query
Request — what changes:
| Field |
Legacy |
New |
| Interval |
interval: str (seconds as string) |
Same |
| Filtering |
filter blob |
filtering structured object |
| Metrics |
Implicit — fixed schema |
specs: List[MetricSpec] — user-defined |
Response — what changes:
|
Legacy OldAnalyticsResponse |
New AnalyticsResponse |
| Buckets |
{total: {count, duration, costs, tokens}, errors: {...}} — hardcoded fields |
{metrics: Dict[str, any]} keyed by spec.path — user-defined |
| Query echo |
Not returned |
query and specs echoed back |
Impact: The web's fetchGenerationsDashboardData is tightly coupled to the fixed bucket schema (total.count, errors.count, etc.). Migration requires changing both the request (add specs) and the response parsing.
2.3 GET /tracing/traces/{id} → GET /traces/{id}
Request: No change (path param only).
Response — what changes:
|
Legacy OTelTracingResponse |
New TraceResponse |
| Shape |
{count, traces: {[traceId]: {spans: {...}}}} — map keyed by trace_id |
{count, trace: {trace_id, spans: [...]}} — single object |
| Key |
traces (plural, record) |
trace (singular, object) |
| Spans |
Nested dict by span name |
Flat list or tree |
Impact: The frontend tracesResponseSchema expects the legacy traces record shape. Migrating requires updating the Zod schema and all consumers of fetchPreviewTrace.
2.4 DELETE /tracing/traces/{id} → DELETE /traces/{id}
Request: No change (path param only).
Response — what changes:
|
Legacy OTelLinksResponse |
New TraceIdResponse |
| Shape |
{count, links: [{trace_id, span_id}]} — list of deleted span links |
{count, trace_id} — just the deleted trace_id |
Impact: Low — the web currently ignores the delete response body.
2.5 POST /tracing/sessions/query → POST /spans/sessions/query
Request: No change — same {realtime?, windowing?} shape.
Response: No change — same {count, session_ids, windowing} shape.
Impact: URL-only change, no schema migration needed.
2.6 Sessions / Users — no web callers for users
POST /tracing/users/query has no web callers. Its replacement POST /spans/users/query is identical in request/response. Migration is a URL swap if/when needed.
Tracing API — Legacy Endpoints & Migration Guide
1. Legacy endpoints currently used by the web
All web calls go through
/tracing/*(deprecated) or/tracing/spans/analytics(legacy, not formally deprecated).POST /tracing/spans/queryfetchAllPreviewTraces(),fetchAllPreviewTracesWithMeta()inweb/oss/src/services/tracing/api/index.tsandweb/packages/agenta-entities/src/trace/api/api.tsPOST /tracing/spans/analyticsfetchGenerationsDashboardData()inweb/oss/src/services/tracing/api/index.tsGET /tracing/traces/{id}fetchPreviewTrace()in both files aboveDELETE /tracing/traces/{id}deletePreviewTrace()in both files abovePOST /tracing/sessions/queryfetchSessions()in both files aboveDeprecated endpoints that web does not call (safe to ignore for web migration):
POST /tracing/spans/ingest,POST /tracing/analytics/query,POST /tracing/traces/,PUT /tracing/traces/{id},POST /tracing/users/query.2. Migration considerations per endpoint
2.1
POST /tracing/spans/query→POST /spans/queryRequest — what changes:
windowing.limit,windowing.oldest/newest(implicit)windowingobject — same struct, but cursor-only;oldest/newestas datetimefilteras freeform JSON blobfilteringas structured{operator, conditions[]}focus: "trace" | "span" | "chat"in bodyfocusremoved — new endpoint always returns flat spans; query revisions withfocus="trace"return 409format: "agenta" | "openai" | ...formattingobject with{focus, format}query_ref/query_variant_ref/query_revision_refResponse — what changes:
OTelTracingResponseSpansResponse{count, spans?, traces?}— one or the other depending onfocus{count, spans}— always flat list, nevertracesfocus="trace"GET /traces/insteadImpact: The web currently relies on
focus="trace"to get the trace-tree shape. The new endpoint drops this entirely. The web would need to either: (a) keep using/tracing/spans/queryuntil a proper trace-tree endpoint migration is scoped, or (b) switch toGET /traces/for trace-tree views andPOST /spans/queryfor flat span views separately.2.2
POST /tracing/spans/analytics→POST /spans/analytics/queryRequest — what changes:
interval: str(seconds as string)filterblobfilteringstructured objectspecs: List[MetricSpec]— user-definedResponse — what changes:
OldAnalyticsResponseAnalyticsResponse{total: {count, duration, costs, tokens}, errors: {...}}— hardcoded fields{metrics: Dict[str, any]}keyed byspec.path— user-definedqueryandspecsechoed backImpact: The web's
fetchGenerationsDashboardDatais tightly coupled to the fixed bucket schema (total.count,errors.count, etc.). Migration requires changing both the request (addspecs) and the response parsing.2.3
GET /tracing/traces/{id}→GET /traces/{id}Request: No change (path param only).
Response — what changes:
OTelTracingResponseTraceResponse{count, traces: {[traceId]: {spans: {...}}}}— map keyed by trace_id{count, trace: {trace_id, spans: [...]}}— single objecttraces(plural, record)trace(singular, object)Impact: The frontend
tracesResponseSchemaexpects the legacytracesrecord shape. Migrating requires updating the Zod schema and all consumers offetchPreviewTrace.2.4
DELETE /tracing/traces/{id}→DELETE /traces/{id}Request: No change (path param only).
Response — what changes:
OTelLinksResponseTraceIdResponse{count, links: [{trace_id, span_id}]}— list of deleted span links{count, trace_id}— just the deleted trace_idImpact: Low — the web currently ignores the delete response body.
2.5
POST /tracing/sessions/query→POST /spans/sessions/queryRequest: No change — same
{realtime?, windowing?}shape.Response: No change — same
{count, session_ids, windowing}shape.Impact: URL-only change, no schema migration needed.
2.6 Sessions / Users — no web callers for users
POST /tracing/users/queryhas no web callers. Its replacementPOST /spans/users/queryis identical in request/response. Migration is a URL swap if/when needed.