refactor(cloud): simplify control-plane logging (M7s)

Merged
SA
21h ago
+535-1247

What and why

A follow-up to #9927 (333fac9c, M7 part 1). That commit was about four times larger than the job (18 files, +1,336 / -205). This PR keeps the same useful outcome and is mostly deletion. Against 333fac9c's parent, the code is now +275 / -35, and the tests are +199 / -20.

  • packages/trpc/src/lib/control-log.ts is now one 43-line file: a ControlEvent union, controlTags, and logControl. There is no barrel, levels map, sink, capture object, errorClass or logStepFailed.
  • 13 events go to Sentry Logs with log.source = "control", cloud_workspace.id, organization.id and, when there is a boot, boot.id: workspace.failed, boot.refused, boot.authorized, boot.released (with its reason), meter.cap_reached, meter.cap_stopped, workspace.asleep, workspace.awake, wake.failed, wake.completed, workspace.archived, archive.stopped, archive.deleted. Keepalive wakes write nothing. An Autumn refusal is a warning and opens no issue.
  • The provision and wake transactions keep the boot.id attribute. Captured exceptions carry the ids as tags, not extra. The three failure sites capture only when the row really moved.
  • All 26 console lines that 333fac9c replaced are back, word for word. The "runs past its limit" line is written before the stop again, and meter.cap_stopped after it.
  • Undone: the settled() closure, bootScope, the third parameter of checkOrFailOpen, and the organizationId threading through the sleep and reap helpers. queueProvision keeps its organizationId parameter, so a provision that cannot be queued writes workspace.failed with both ids.
  • isUsageRefusal is removed. isCloudUsageRefusal in @superset/shared/billing now reads the key from data (what clients get) or from cause (the server's own TRPCError).
  • enableLogs: true stays explicit in the API's Sentry config. The evidence page shows the line in @sentry/core 10.75.2 where the default is set.

No billing call or status write changed. The verify-sandbox-asleep model check passes.

What breaks, and for whom

Nothing breaks. No tRPC procedure changed. Desktop and mobile get the same result from isCloudUsageRefusal as before. These events are no longer written: workspace.created, workspace.unarchived, provision.*, wake.started, restart.started, boot.attached, boot.adopted, meter.settled, meter.settle_failed, archive.hook_ran, step.failed. They shipped today, so nothing reads them yet.

Links

šŸ¤– Generated with Claude Code


Summary by cubic

Follow-up to the larger logging commit: the control-plane event framework is now one small control-log.ts helper (43 lines) with the same behavior at about a third of the size. 13 events still go to Sentry Logs with workspace, organization, and boot ids, and the console lines it replaced are back word for word.

What to know

  • enableLogs: true is kept explicit in the API's Sentry config rather than relying on the @sentry/core 10.75.2 default.
  • queueProvision takes the organization id again, so a provision that cannot be queued writes workspace.failed with both ids and tags its capture with both.
  • workspace.created, provision.*, wake.started, restart.started, boot.attached, boot.adopted, meter.settled, meter.settle_failed, archive.hook_ran, and step.failed are no longer written; nothing reads them yet.
  • Captured exceptions only fire when the status row actually moved, and carry ids as tags instead of extra.
  • isCloudUsageRefusal now reads the key from data (clients) or cause (server); isUsageRefusal is gone.

No billing call, status write, or tRPC procedure changed.