You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 23, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 23, 2026. It is now read-only.
Add CLI support for fetching logs associated with a trace #247
Provide a CLI way to fetch logs associated with a trace — the same logs shown in the trace UI "Logs" tab.
Current State
There is no dedicated "logs per trace" command. Attempting sentry log list -q "trace:<trace-id>" does not work because the current implementation queries the Explore/Events logs dataset endpoint (/organizations/{org}/events/?dataset=logs), which does not support filtering by trace ID in query syntax.
Technical Finding
Trace logs must be fetched via a dedicated endpoint:
GET /organizations/{org}/trace-logs/?traceId=<trace-id>&statsPeriod=<period>
Key details:
statsPeriod is required — without it, the API may return an empty result set even when logs exist for the trace.
The response schema differs from the Explore/Events logs endpoint (e.g. id instead of sentry.item_id, includes project.id and severity_number).
Add first-class trace logs support to the CLI. Options to consider:
Option A: Extend sentry log list with --trace-id
sentry log list --trace-id <trace-id>
sentry log list -t <trace-id>
When --trace-id is provided, route to the /trace-logs/ endpoint instead of /events/?dataset=logs. Would also need to handle statsPeriod (either a sensible default like 14d, or expose via --period flag). Note: the trace-logs/ endpoint is org-scoped (no project required), so project resolution could become optional in this path.
A subcommand under the trace group, aligned with the API structure. Clear separation from the existing sentry log list / sentry log view commands.
Design Considerations
Avoid ambiguity with existing log view: sentry log view currently views a single log entry by its item ID. A syntax like <org>/<project>@<id> could be ambiguous between event-id and trace-id. Prefer:
A flag (--trace-id), and/or
A dedicated trace logs command namespace, and/or
A clearly non-ambiguous trace-specific identifier format (trace IDs are 32-char hex)
statsPeriod handling: The API requires it. A default (e.g. 14d) is needed, with an optional override flag.
--follow compatibility: If extending sentry log list, consider whether --follow + --trace-id should be supported or treated as mutually exclusive.
Activity
betegon commentedon Feb 17, 2026
thanks @philprime for the idea and brainstorming <3
feat(trace): add `sentry trace logs` subcommand (#247)
feat(trace): add `sentry trace logs` subcommand (#247) (#311)