Add error monitoring for Shape critical paths#3
Merged
Conversation
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 Magic — advisoryNot ready to rely on for release readiness Unresolved:
Show what this relies on · Report · Chain #31 · Advisory only. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 whenSHAPE_MONITORING_DSNis set; no-op otherwise. Fire-and-forget withkeepaliveso 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 withengine/profilecontext.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.