Skip to content

Add error monitoring for Shape critical paths#3

Merged
fentonbenjamin merged 4 commits into
mainfrom
setup/add-monitoring
May 9, 2026
Merged

Add error monitoring for Shape critical paths#3
fentonbenjamin merged 4 commits into
mainfrom
setup/add-monitoring

Conversation

@fentonbenjamin
Copy link
Copy Markdown
Owner

Adds a minimal DSN-gated error reporter and wires it into the two Shape critical paths.

What changes

  • lib/monitoring.ts (new) — Sentry-compatible POST when SHAPE_MONITORING_DSN is set; no-op otherwise. Fire-and-forget with keepalive so the request path isn't blocked on egress. Monitor-internal failures must not crash the caller.
  • app/api/shape/route.ts — report 5xx-bound errors with engine / profile context.
  • lib/engine.ts — report JSON parse failures from the model with a truncated raw preview for triage.

Why

Without this, model failures, JSON parse errors, and provider outages disappear into a 500 with no alerting. This is the minimum monitoring surface for Shape's API.

Phase 1.1 setup

This is the setup PR for the canonical Phase 1.1 demo. The follow-up PR removes this code and is the actual Not Magic detection target.

When SHAPE_MONITORING_DSN is configured, server-side errors in the
Shape API route and engine are reported to the monitoring backend
(Sentry-compatible payload). Without the DSN, the helper is a
no-op so local development and unauthenticated previews emit no
telemetry.

- lib/monitoring.ts: minimal DSN-gated reporter, fire-and-forget
  POST with keepalive so request paths aren't blocked on egress.
  Failures inside the monitor don't crash the caller.
- app/api/shape/route.ts: report 5xx-bound errors with engine /
  profile context.
- lib/engine.ts: report JSON parse failures from the model with a
  truncated raw preview for triage.

Without this, model failures, JSON parse errors, and provider
outages disappear into a 500 with no alerting.
@not-a-magic
Copy link
Copy Markdown

not-a-magic Bot commented May 9, 2026

Not Magic — advisory

Not ready to rely on for release readiness

Unresolved:

  • observability
  • general

Show what this relies on · Report · Chain #31 · Advisory only.

@fentonbenjamin fentonbenjamin merged commit b8dba93 into main May 9, 2026
1 check failed
@fentonbenjamin fentonbenjamin deleted the setup/add-monitoring branch May 9, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant