Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(astro): Add Astro 5 support #14613

Merged
merged 7 commits into from
Dec 10, 2024
Merged

feat(astro): Add Astro 5 support #14613

merged 7 commits into from
Dec 10, 2024

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Dec 6, 2024

This PR adds support for Astro 5 and an E2E test app for Astro 5 with the new server islands feature.

I tested server islands and found out that we emit a new http.server transaction for the island-specific additional http requests. Which is generally good IMO, given that server island requests are routed to the automatically generated /_server-island/[name] Astro endpoint.

Why are island requests not trace-connected?

The unfortunate part is that the request made from the browser to the island endpoint on the server is not connected to the same trace as the previous pageload. The reason for this is that the island request is optimized by Astro to be made as early as possible:

  <body data-astro-cid-sckkx6r4>
    <link
      rel="preload"
      as="fetch"
      href="/_server-islands/Avatar?e=default&p=90E4B650D5FB9C79B093A46ACQTwMnk0g4KcHJnjA6eqCAWA&s=%7B%7D"
      crossorigin="anonymous"
    />
    <script async type="module" data-island-id="5e569be4-6990-4e91-adbb-f2632656ba4f">
      let response = await fetch(
        '/_server-islands/Avatar?e=default&p=90E4B650D5FB9C79B093A46ACQTwMnk0g4KcHJnjA6eqCAWA&s=%7B%7D',
      );
    </script>
  </body>

IIUC as="fetch" correctly, this preloads the request and no new request is made for the actual fetch() call. Our pageload transaction even includes a resource.link span for the request. However, given the fetch() request isn't really made, we can't attach headers or record an http.client span for it.

IMHO there is also a "good" part to this: Usually, Astro server islands are supposed to be used on statically rendered pages. So the traceId that is currently injected into the <meta> tags stays constant across all page loads. Meaning if the server endpoint requests were also connected to this trace, it would further blow up the transactions in the trace.

Long term, we ideally don't add a <meta> tag to statically generated pages but let the pageload transaction on the client be head of trace. Then, connecting the server island requests to this pageload would be ideal, if we ever find a way to make this work.

@Lms24 Lms24 self-assigned this Dec 6, 2024
@Lms24 Lms24 requested review from mydea and chargome December 6, 2024 13:02
Comment on lines -8 to +14
"withastro",
"astro-component",
"astro-integration",
"sentry",
"apm"
],
"keywords": ["withastro", "astro-component", "astro-integration", "sentry", "apm"],
"author": "Sentry",
"license": "MIT",
"engines": {
"node": ">=18.14.1"
},
"type": "module",
"files": [
"/build"
],
"files": ["/build"],
Copy link
Member Author

Choose a reason for hiding this comment

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

these are just auto-format changes

Copy link

codecov bot commented Dec 6, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
245 1 244 9
View the top 1 failed tests by shortest run time
client-app-routing-instrumentation.test.ts Creates a navigation transaction for app router routes
Stack Traces | 30s run time
client-app-routing-instrumentation.test.ts:19:5 Creates a navigation transaction for app router routes

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

LGTM!

Maybe we can delete the .vscode folder in the test though

Copy link
Contributor

github-actions bot commented Dec 6, 2024

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.19 KB - -
@sentry/browser - with treeshaking flags 21.87 KB - -
@sentry/browser (incl. Tracing) 35.68 KB - -
@sentry/browser (incl. Tracing, Replay) 72.91 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 63.31 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 77.22 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 89.71 KB - -
@sentry/browser (incl. Feedback) 39.95 KB - -
@sentry/browser (incl. sendFeedback) 27.81 KB - -
@sentry/browser (incl. FeedbackAsync) 32.6 KB - -
@sentry/react 25.87 KB - -
@sentry/react (incl. Tracing) 38.5 KB - -
@sentry/vue 27.4 KB - -
@sentry/vue (incl. Tracing) 37.52 KB - -
@sentry/svelte 23.36 KB - -
CDN Bundle 24.36 KB - -
CDN Bundle (incl. Tracing) 37.34 KB - -
CDN Bundle (incl. Tracing, Replay) 72.53 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 77.89 KB - -
CDN Bundle - uncompressed 71.56 KB - -
CDN Bundle (incl. Tracing) - uncompressed 110.85 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 224.92 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 238.13 KB - -
@sentry/nextjs (client) 38.79 KB - -
@sentry/sveltekit (client) 36.18 KB - -
@sentry/node 162.93 KB - -
@sentry/node - without tracing 99.81 KB -0.01% -1 B 🔽
@sentry/aws-serverless 127.3 KB +0.01% +1 B 🔺

View base workflow run

@Lms24 Lms24 merged commit 7f0bd25 into develop Dec 10, 2024
128 checks passed
@Lms24 Lms24 deleted the lms/astro-5 branch December 10, 2024 07:10
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.

2 participants