Skip to content

cold-start: tune Sentry sampling and Vercel function limits#45

Merged
x0ba merged 3 commits into
stagingfrom
cold-start/tune-sentry-vercel
May 28, 2026
Merged

cold-start: tune Sentry sampling and Vercel function limits#45
x0ba merged 3 commits into
stagingfrom
cold-start/tune-sentry-vercel

Conversation

@x0ba
Copy link
Copy Markdown
Owner

@x0ba x0ba commented May 28, 2026

Stack Context

This stack reduces Vercel cold-start time by shrinking the shared SvelteKit server boot path and isolating heavy agent/GitHub dependencies.

Why?

Full Sentry trace sampling and server instrumentation added startup overhead on every cold boot. This PR lowers production sampling, disables Sentry server tracing on Vercel, and sets maxDuration on long-running agent and webhook routes.

Test plan

  • Confirm Sentry still receives errors in production
  • Confirm agent run and webhook routes respect extended timeouts on Vercel

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flightlog Ready Ready Preview, Comment May 28, 2026 4:59pm

Copy link
Copy Markdown
Owner Author

x0ba commented May 28, 2026

@x0ba x0ba changed the title Reduce server observability overhead and tune Vercel function limits. cold-start: tune Sentry sampling and Vercel function limits May 28, 2026
@x0ba x0ba marked this pull request as ready for review May 28, 2026 07:56
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Greptile Summary

This PR reduces Vercel cold-start overhead by disabling SvelteKit's experimental OpenTelemetry server tracing on Vercel (while keeping Sentry initialisation intact), lowering Sentry's production trace sample rate from 100 % to 10 %, and adding export const config = { maxDuration } to long-running API routes using the @sveltejs/adapter-vercel Config API.

  • svelte.config.js: tracing.server is gated on !VERCEL, but instrumentation.server remains true, so Sentry.init() still runs and sentryHandle() / handleErrorWithSentry() in hooks.server.ts continue to capture errors in production.
  • src/instrumentation.server.ts: tracesSampleRate drops from 1.0 to 0.1 in production builds via import.meta.env.PROD, cutting performance-tracing ingestion cost while preserving error and log capture.
  • Seven route files add per-route maxDuration values (60 s for the GitHub webhook, 300 s for agent, stream, and all regression endpoints), which the adapter writes directly into each function's Vercel Build Output API config.

Confidence Score: 5/5

Safe to merge — the changes are narrowly scoped to Vercel configuration and do not touch any application logic.

SvelteKit's OpenTelemetry tracing is disabled only on Vercel builds, while instrumentation.server remains true, keeping Sentry initialised and error reporting fully operational. The trace sample-rate change is a build-time constant swap with no runtime risk. All maxDuration exports use the correct adapter-level API, which is the authoritative path for the Build Output API. No application logic was changed.

No files require special attention.

Important Files Changed

Filename Overview
svelte.config.js Disables SvelteKit's server-side OpenTelemetry tracing on Vercel via process.env.VERCEL !== '1'; instrumentation.server stays true so Sentry is still initialised and error reporting is unaffected.
src/instrumentation.server.ts Lowers tracesSampleRate to 0.1 in production via build-time import.meta.env.PROD replacement; Sentry error and log capture is unchanged.
src/routes/api/agent-runs/+server.ts Adds maxDuration: 300 adapter config; appropriate for a route that spawns long-running agent work.
src/routes/api/github/webhook/+server.ts Adds maxDuration: 60; reasonable for a webhook handler that may do async GitHub API work.
src/routes/api/runs/[id]/stream/+server.ts Adds maxDuration: 300 for the SSE streaming endpoint; necessary to keep the serverless function alive for the full agent-run lifetime.
src/routes/api/regression/suites/[id]/runs/+server.ts Adds maxDuration: 300; the POST schedules a regression run and GET lists runs — both are quick DB operations, but 300 s is harmless and keeps the file consistent with sibling routes.
src/routes/api/regression/runs/[id]/cases/[caseId]/complete/+server.ts Adds maxDuration: 300; appropriate for a route that completes a regression case run which may involve evaluation logic.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Vercel Cold Start] --> B{VERCEL eq 1?}
    B -- Yes --> C[tracing.server = false\nSvelteKit OTEL disabled]
    B -- No --> D[tracing.server = true\nSvelteKit OTEL enabled]
    C --> E[instrumentation.server = true\nSentry.init called]
    D --> E
    E --> F{PROD build?}
    F -- Yes --> G[tracesSampleRate = 0.1]
    F -- No --> H[tracesSampleRate = 1.0]
    G --> I[Sentry errors and logs captured]
    H --> I
    subgraph Route maxDuration
        J[agent-runs: 300s]
        K[runs stream: 300s]
        L[github webhook: 60s]
        M[regression routes: 300s]
    end
Loading

Reviews (6): Last reviewed commit: "address greptile review feedback (greplo..." | Re-trigger Greptile

Comment thread svelte.config.js
Comment thread vercel.json Outdated
Comment thread vercel.json Outdated
@x0ba
Copy link
Copy Markdown
Owner Author

x0ba commented May 28, 2026

@greptile review

@x0ba
Copy link
Copy Markdown
Owner Author

x0ba commented May 28, 2026

@greptile review

Copy link
Copy Markdown
Owner Author

x0ba commented May 28, 2026

Merge activity

  • May 28, 4:49 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 28, 4:58 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 28, 4:58 PM UTC: @x0ba merged this pull request with Graphite.

@x0ba x0ba changed the base branch from cold-start/split-db-drivers to graphite-base/45 May 28, 2026 16:55
@x0ba x0ba changed the base branch from graphite-base/45 to staging May 28, 2026 16:56
x0ba and others added 3 commits May 28, 2026 16:57
Lowers Sentry trace sampling in production, disables server tracing on Vercel, and sets maxDuration for long-running agent and webhook routes.
Keep Sentry instrumentation enabled on Vercel while disabling only server tracing, move maxDuration to adapter-level config on regression routes, and remove redundant vercel.json function entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
Re-enable Sentry server instrumentation while keeping Vercel-only tracing disabled.

Co-authored-by: Cursor <cursoragent@cursor.com>
@x0ba x0ba force-pushed the cold-start/tune-sentry-vercel branch from 9c30bd4 to f1f144f Compare May 28, 2026 16:57
@x0ba x0ba merged commit 548a3c6 into staging May 28, 2026
4 of 5 checks passed
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