Skip to content

feat(sveltekit): Add performance monitoring to Sveltekit server handle #7532

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

Merged
merged 8 commits into from
Mar 21, 2023

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Mar 20, 2023

ref #7526

In this PR we start tracking the performance of the SvelteKit server-side routes via the handle function.

// src/hooks.server.ts
import { sentryHandle } from '@sentry/sveltekit';

export const handle = sentryHandle;

// Optionally use the sequence function to add additional handlers.
// export const handle = sequence(sentryHandle, yourCustomHandle);

If you do use a sequence function, you should place the sentryHandle as your first so that the transaction duration for the api request is as accurate as possible.

image

@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.53 KB (+0.01% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 63.85 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 19.19 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 56.92 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 21.66 KB (0%)
@sentry/browser - Webpack (minified) 72.12 KB (0%)
@sentry/react - Webpack (gzipped + minified) 21.7 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 52.05 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 33.76 KB (+0.01% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 26.13 KB (0%)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 44.23 KB (+0.01% 🔺)
@sentry/replay - Webpack (gzipped + minified) 38.28 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 62.45 KB (+0.01% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 55.99 KB (+0.01% 🔺)

@AbhiPrasad AbhiPrasad marked this pull request as ready for review March 20, 2023 17:44
@AbhiPrasad AbhiPrasad changed the title feat(sveltekit): Add performance monitoring to Sveltekit handle feat(sveltekit): Add performance monitoring to Sveltekit server handle Mar 20, 2023
@AbhiPrasad AbhiPrasad requested review from a team, mydea and Lms24 and removed request for a team March 20, 2023 18:47
@AbhiPrasad
Copy link
Member Author

AbhiPrasad commented Mar 20, 2023

Playing around with wiring up https://github.com/sveltejs/sites/tree/master/sites/hn.svelte.dev

image

We'll need server-side fetch support for this though (I locally did monkeypatching to get the http.client spans)

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Looks good to me!
Just had a comment about tests.

expect(e.message).toEqual(type);
}

if (!isError) {
Copy link
Member

Choose a reason for hiding this comment

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

m: hmm not really a fan of conditional paths in tests. Makes tests harder to understand and also feels like we're testing different scenarios in one test. To me (maybe just personal preference), it seems like we're misusing each here a little. That being said, if we split the isError cases to separate tests, we probably end up with a ton of duplicated code, right?

I'll leave this up to you: If refactoring these tests results in too much duplication or work, I'm fine with leaving it as is. Generally though, let's try to avoid conditional expects and test paths.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I struggled with this a little, but one of the issues here is that there are 4 different scenarios we need to account for.

  1. Async and no error
  2. Async and throw an error
  3. Sync and no error
  4. Sync and throws no error

Let me try cleaning it up so we can remove the isError checks.

Copy link
Member Author

Choose a reason for hiding this comment

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

@AbhiPrasad AbhiPrasad merged commit 15a36bc into develop Mar 21, 2023
@AbhiPrasad AbhiPrasad deleted the abhi-sveltekit-server-handle branch March 21, 2023 12:17
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