Skip to content

feat(apidocs): Publish trace-logs endpoint - #130357

Merged
BYK merged 2 commits into
masterfrom
byk/feat/apidocs-publish-trace-logs
Nov 7, 2026
Merged

BYK merged 2 commits into
masterfrom
byk/feat/apidocs-publish-trace-logs

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Publishes GET /api/0/organizations/{organization_id_or_slug}/trace-logs/ (OrganizationTraceLogsEndpoint, owner Data Browsing) in the public API schema, so it reaches the generated @sentry/api SDK.

This comes from the #130351 proposal. The Sentry CLI is moving every call onto @sentry/api operations (getsentry/toolkit#2073). Its log list and trace logs commands still call this endpoint by hand because it isn't in the schema.

Evidence:

The response type was list[dict[str, Any]], which the response-coverage check rejects for public operations. The endpoint always selects the same eight columns, so each row is now a TraceLog TypedDict, and every field has an ApiDescription.

I checked the types against a real response from the endpoint:

  • project.id and timestamp_precise are integers. The example's timestamp_precise was a float, so it's now an integer.
  • timestamp is ISO 8601.
  • confidence is one empty object per row, because logs aren't aggregated.
  • full_scan, bytes_scanned and routingHint are optional, because a mocked or empty RPC meta can leave them out.

The only change to the built schema (make build-api-docs, diffed against master) is the new listOrganizationTraceLogs operation and its TraceLogsResponse component. The new apidocs test validates a stored log against the schema.

Publishing the endpoint also adds it to the agent token public GET matrix in tests/sentry/seer/endpoints/test_organization_agent_token.py. The endpoint returns 400 without a traceId or replayId, so the matrix now passes a traceId, the same way it handles other endpoints that need query params. That test file passes locally.

tests/snuba/api/endpoints/test_organization_trace_logs.py::test_simple failed once under -n3. It passes when the file runs serially. The likely cause is that the tests share trace IDs in Snuba when they run in parallel, but I haven't confirmed that.

The "(Optional) Shows the difference between the prod and dev schema" check is expected to fail, because this PR changes the schema.

via @BYK.

--

View Session [Sentry]

Publish GET /organizations/{org}/trace-logs/ in the public API schema so
it reaches @sentry/api. Type each log row and describe every response
field, and fix the example's timestamp_precise, which the endpoint
returns as an integer.

Refs #130351

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@sentry-junior
sentry-junior Bot requested review from a team as code owners November 7, 2026 15:44
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 7, 2026
Publishing the trace-logs endpoint adds it to the agent token public GET
matrix. The endpoint returns 400 without a traceId or replayId, so give
it one like the other endpoints that need query params.
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner November 7, 2026 16:04
@BYK
BYK enabled auto-merge (squash) November 7, 2026 16:04
@BYK
BYK merged commit 950f9f8 into master Nov 7, 2026
78 of 79 checks passed
@BYK
BYK deleted the byk/feat/apidocs-publish-trace-logs branch November 7, 2026 16:08
BYK added a commit to getsentry/toolkit that referenced this pull request Nov 7, 2026
… revision operations (#2093)

Next batch of moving the CLI onto `@sentry/api` generated operations
(follows #2073, #2075, #2078, #2090).

`@sentry/api` 1.49.0 publishes three endpoints the CLI already calls:

| CLI function | Endpoint | Operation | Published by |
| --- | --- | --- | --- |
| `listTraceLogs` (`log list --trace`, `trace logs`) | `GET
/organizations/{org}/trace-logs/` | `listOrganizationTraceLogs` |
getsentry/sentry#130357 |
| `listDashboardRevisionsPaginated` (`dashboard revisions`) | `GET
/organizations/{org}/dashboards/{id}/revisions/` |
`listOrganizationDashboardRevisions` | getsentry/sentry#130358 |
| `restoreDashboardRevision` (`dashboard restore`) | `POST
/organizations/{org}/dashboards/{id}/revisions/{rev}/restore/` |
`restoreOrganizationDashboardRevision` | getsentry/sentry#130358 |

These calls stop using `apiRequestToRegion` and behave the same as
before:
- The CLI's valibot schemas still validate each response, so schema
mismatches still fail as "Unexpected response format".
- Region routing goes through `getOrgSdkConfig`.
- Pagination still uses the Link-header cursors, including the previous
cursor for revisions.
- 401/403 errors are still enriched by `unwrapResult`.
- On the wire, `traceId` and `sort` are sent as single repeated params,
the same as before.
- The dashboard and revision ids are passed as strings with the same
cast `getDashboard` uses. The SDK URL-encodes them the way the old code
did.

All three operations have `experimental: false`.

Bumping to 1.49.0 also pulls in the 1.47.0 regen and 1.48.0's
`experimental` flag. Typecheck and generated docs don't change.

### Still on the helpers

| Call site | Endpoint | Waiting on |
| --- | --- | --- |
| `issues.ts` `getSharedIssue` (raw fetch) | `GET
/shared/issues/{share_id}/` | getsentry/sentry#130359 merged after the
1.49.0 regen, so it needs the next release |
| `releases.ts` set-commits | `GET
/organizations/{org}/releases/{version}/previous-with-commits/` | same
as above (#130359) |
| `org-auth-tokens.ts` (3 sites) | list/create/delete
`/organizations/{org}/org-auth-tokens/` | getsentry/sentry#130360
(auto-merging) |
| `projects.ts` dsn-lookup | `GET /organizations/{org}/dsn-lookup/` |
getsentry/sentry#130367 |
| `auth.ts` | `GET /api/0/` (control silo) | getsentry/sentry#130369 |
| `users.ts` | `GET /auth/` → `GET /users/me/` | getsentry/sentry#130368
|
| `organizations.ts` | `GET /users/me/regions/` | #2091 replaces it with
`listOrganizations` |
| `traces.ts` / `logs.ts` | `GET
/projects/{org}/{project}/trace-items/{id}/` | sentry publish PR still
to come |
| `preprod-artifacts.ts` | build assemble, snapshot archive status and
trigger, snapshot create (zstd body) | sentry publish PRs still to come
|
| `projects.ts` | `GET /projects/?query=dsn:` fallback for old
self-hosted servers | not public; needs a decision (see below) |

These are the agreed exceptions: `trials.ts` (`/customers/*` and the
product-trial PUT), snapshot `upload-options` and archive `?download`,
`downloadBuildArtifact`'s install URL, chunk-upload server URLs, and
`rawApiRequest` for `sentry api`.

**Needs a decision:** the self-hosted DSN fallback from #2090 calls `GET
/projects/?query=dsn:`, which isn't in the public schema. It needs to be
added to the exception list for the lint rule, or dropped once old
self-hosted versions age out.

### Testing

- `pnpm run tsc` and `pnpm run lint` pass.
- `pnpm run test` fails only on the 5 file-permission tests that also
fail on `main` in the sandbox (`completions` ×2, `upgrade`,
`db/resilient`, `dsn/code-scanner`), plus `@sentry/cli3to4`, whose
codemod binary needs GLIBC 2.35.
- Added unit tests for the revision list (cursors, schema rejection) and
for restore (operation args, error naming). The trace-logs test now
checks `traceId` and `sort` on the wire.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A80220b9d4c297e2a971f05dcb03af515 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <126780+BYK@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant