Skip to content

feat(astro): Auto-wire orchestrion build-time instrumentation - #22830

Merged
chargome merged 7 commits into
developfrom
cg/astro-orchest
Jul 30, 2026
Merged

feat(astro): Auto-wire orchestrion build-time instrumentation#22830
chargome merged 7 commits into
developfrom
cg/astro-orchest

Conversation

@chargome

@chargome chargome commented Jul 29, 2026

Copy link
Copy Markdown
Member

sentryAstro() now injects the orchestrion bundler plugin into the Vite config automatically during astro:config:setup, so instrumented server-side dependencies get diagnostics_channel publishers injected into the SSR bundle at build time with no manual plugin setup.

The astro-7-orchestrion e2e app is migrated off its manual vite.plugins: [sentryOrchestrionPlugin()] wiring to prove the built-in path.

dev server investigation postponed to #22857

closes #22686

@chargome chargome self-assigned this Jul 29, 2026
@chargome

chargome commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

bugborzer run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f72aa25. Configure here.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.82 kB - -
@sentry/browser - with treeshaking flags 28.02 kB - -
@sentry/browser (incl. Tracing) 47.08 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.09 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.82 kB - -
@sentry/browser (incl. Tracing, Replay) 86.39 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.83 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 91.11 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.76 kB - -
@sentry/browser (incl. Feedback) 47.13 kB - -
@sentry/browser (incl. sendFeedback) 34.66 kB - -
@sentry/browser (incl. FeedbackAsync) 39.76 kB - -
@sentry/browser (incl. Metrics) 30.89 kB - -
@sentry/browser (incl. Logs) 31.12 kB - -
@sentry/browser (incl. Metrics & Logs) 31.8 kB - -
@sentry/react 31.6 kB - -
@sentry/react (incl. Tracing) 49.33 kB - -
@sentry/vue 34.74 kB - -
@sentry/vue (incl. Tracing) 49.05 kB - -
@sentry/svelte 29.85 kB - -
CDN Bundle 31.87 kB - -
CDN Bundle (incl. Tracing) 47.45 kB - -
CDN Bundle (incl. Logs, Metrics) 33.42 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 48.82 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.78 kB - -
CDN Bundle (incl. Tracing, Replay) 85.08 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 90.85 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.16 kB - -
CDN Bundle - uncompressed 95.04 kB - -
CDN Bundle (incl. Tracing) - uncompressed 142.27 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.75 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 146.25 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 224.51 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 261.52 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 265.49 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 275.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 279.18 kB - -
@sentry/nextjs (client) 51.92 kB - -
@sentry/sveltekit (client) 47.51 kB - -
@sentry/core/server 79.59 kB - -
@sentry/core/browser 51.58 kB - -
@sentry/node 121.27 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B - -
@sentry/node - without tracing 84.77 kB +0.01% +2 B 🔺
@sentry/aws-serverless 93.02 kB - -
@sentry/cloudflare (withSentry) - minified 197.59 kB - -
@sentry/cloudflare (withSentry) 485.77 kB - -

View base workflow run

chargome and others added 3 commits July 30, 2026 10:21
The multi-line hook-call argument pushed the `AstroIntegrationLogger` type
mismatch onto the `logger` property line, past the single `@ts-expect-error`
covering the call. Collapse to a single-line call (matching the sibling
deprecation test) so the suppression covers the whole argument.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chargome
chargome marked this pull request as ready for review July 30, 2026 09:06
@chargome
chargome requested a review from a team as a code owner July 30, 2026 09:06
@chargome
chargome requested review from andreiborza, nicohrubec and s1gr1d and removed request for a team July 30, 2026 09:06
Comment on lines +178 to +184
if (sdkEnabled.server && !isCloudflare) {
updateConfig({
vite: {
plugins: [sentryOrchestrionPlugin({ buildTimeInstrumentation }) as VitePlugin],
},
});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The orchestrion plugin is unconditionally injected in dev mode, causing its config() hook to add ssr.noExternal settings, which unnecessarily bundles packages and degrades performance.
Severity: MEDIUM

Suggested Fix

Wrap the updateConfig call for the orchestrion plugin in a condition that checks if the Astro command is not 'dev', similar to how the sourcemaps plugin is handled. This will prevent the plugin from being injected and its config() hook from running during development.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/astro/src/integration/index.ts#L178-L184

Potential issue: The Sentry orchestrion plugin is injected unconditionally when
`sdkEnabled.server` is true, without checking if the Astro command is `dev`. While the
plugin's `applyToEnvironment` hook prevents code transformations, its `config()` hook
still executes. This hook injects `ssr.noExternal` configurations into the Vite config
during development. As a result, Vite is forced to bundle server-side packages (e.g.,
`mysql`, `ioredis`) that are not needed for the dev server, leading to degraded
performance. This affects all users running the Astro dev server with the default Sentry
integration settings.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would they not be needed for dev?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding a test

@nicohrubec nicohrubec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Add `test:dev` (TEST_ENV=development, `astro dev`) alongside the existing
production run and make `test:assert` run both, mirroring the nextjs e2e apps.
This exercises the auto-wired orchestrion transform in Vite's dev SSR path, not
just the production bundle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chargome
chargome merged commit 7ea1a00 into develop Jul 30, 2026
95 checks passed
@chargome
chargome deleted the cg/astro-orchest branch July 30, 2026 11:38
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.

Astro: auto-wire orchestrion bundler plugin

3 participants