Skip to content

Trace does not include server load spans in dev environment #12688

@joemmalatesta

Description

@joemmalatesta

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/sveltekit

SDK Version

8.11.0

Framework Version

SvelteKit 2.0.0

Link to Sentry event

No response

SDK Setup/Reproduction Example

// src/hooks.client.ts
import { handleErrorWithSentry, replayIntegration } from '@sentry/sveltekit';
import * as Sentry from '@sentry/sveltekit';

Sentry.init({
	dsn: {DSN}
	tracesSampleRate: 1.0,

	// This sets the sample rate to be 10%. You may want this to be 100% while
	// in development and sample at a lower rate in production
	replaysSessionSampleRate: 0.1,

	// If the entire session is not sampled, use the below sample rate to sample
	// sessions when an error occurs.
	replaysOnErrorSampleRate: 1.0,

	// If you don't want to use Session Replay, just remove the line below:
	integrations: [
		replayIntegration(),
		Sentry.feedbackIntegration({
			// Additional SDK configuration goes in here, for example:
			colorScheme: 'light'
		}),
	],
});

// If you have a custom error handler, pass it to `handleErrorWithSentry`
export const handleError = handleErrorWithSentry();
// src/hooks.client.ts
import { sequence } from "@sveltejs/kit/hooks";
import { handleErrorWithSentry, sentryHandle } from "@sentry/sveltekit";
import * as Sentry from '@sentry/sveltekit';

Sentry.init({
  dsn: {DSN}
  tracesSampleRate: 1.0,

  // uncomment the line below to enable Spotlight (https://spotlightjs.com)
  // spotlight: import.meta.env.DEV,  
});

// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.
export const handle = sequence(sentryHandle());

// If you have a custom error handler, pass it to `handleErrorWithSentry`
export const handleError = handleErrorWithSentry();

Steps to Reproduce

repo available at https://github.com/joemmalatesta/osumon.

When running in a development environment using npm run dev, the spans for requests made in load functions for routes like src/routes/v1/[username]/+page.server/ts are not included unless manually instrumented using Sentry.startSpan() This image shows the trace for a load function in a development environment.
image

However, this is not the case in production or running a prod environment locally using npm run build and npm run preview. In this case, the spans will be sent as expected (as seen in expected result)

Expected Result

image

Actual Result

image

Metadata

Metadata

Assignees

Labels

Projects

Status

Waiting for: Community

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions